Skip to content

Commit

Permalink
chore: Catch server health checker errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Dschoordsch committed Dec 10, 2024
1 parent 2741491 commit 6e11a7a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
3 changes: 2 additions & 1 deletion packages/server/listenHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {us_listen_socket} from 'uWebSockets.js'
import getGraphQLExecutor from './utils/getGraphQLExecutor'
import {Logger} from './utils/Logger'
import serverHealthChecker from './utils/serverHealthChecker'
import sendToSentry from './utils/sendToSentry'

const listenHandler = (listenSocket: us_listen_socket) => {
const PORT = Number(__PRODUCTION__ ? process.env.PORT : process.env.SOCKET_PORT)
Expand All @@ -10,7 +11,7 @@ const listenHandler = (listenSocket: us_listen_socket) => {
Logger.log(`\nπŸ”₯πŸ”₯πŸ”₯ Server ID: ${SERVER_ID}. Ready for Sockets: Port ${PORT} πŸ”₯πŸ”₯πŸ”₯`)
getGraphQLExecutor().subscribe()
// Cleaning on startup because shutdowns may be abrupt
serverHealthChecker.cleanUserPresence()
serverHealthChecker.cleanUserPresence().catch(sendToSentry)
} else {
Logger.log(`❌❌❌ Port ${PORT} is in use! ❌❌❌`)
}
Expand Down
2 changes: 0 additions & 2 deletions packages/server/utils/serverHealthChecker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {disconnectQuery} from '../socketHandlers/handleDisconnect'
import {Logger} from './Logger'
import RedisInstance from './RedisInstance'
import publishInternalGQL from './publishInternalGQL'
import sendToSentry from './sendToSentry'

const SERVER_ID = process.env.SERVER_ID!
const INSTANCE_ID = `${SERVER_ID}:${process.pid}`
Expand Down Expand Up @@ -84,7 +83,6 @@ class ServerHealthChecker {
await new Promise((resolve, reject) => {
userPresenceStream.on('end', resolve)
userPresenceStream.on('error', (e) => {
sendToSentry(e)
reject(e)
})
})
Expand Down

0 comments on commit 6e11a7a

Please sign in to comment.