Skip to content

Commit

Permalink
log the disconnects
Browse files Browse the repository at this point in the history
Signed-off-by: Matt Krick <[email protected]>
  • Loading branch information
mattkrick committed Feb 7, 2025
1 parent 32f432f commit fcf7ab6
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/server/graphql/mutations/setAppLocation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export default {
return url?.includes(meetPrefix) ? url.slice(meetPrefix.length) : null
})

console.log('setAtLocation', connectedSocketStr, JSON.stringify(updatedConnection))
const [lastMeeting, nextMeeting] = await Promise.all([
lastMeetingId ? dataLoader.get('newMeetings').load(lastMeetingId) : undefined,
nextMeetingId ? dataLoader.get('newMeetings').load(nextMeetingId) : undefined,
Expand Down
2 changes: 1 addition & 1 deletion packages/server/graphql/private/mutations/connectSocket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const connectSocket: MutationResolvers['connectSocket'] = async (
`presence:${userId}`,
JSON.stringify({lastSeenAtURL: null, socketInstanceId, socketId} as UserPresence)
)

console.log('connectSocket pushed presence', socketInstanceId, socketId)
// If this is the first socket, tell everyone they're online
if (socketCount === 1) {
const listeningUserIds = await getListeningUserIds(RedisCommand.ADD, tms, userId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const disconnectSocket: MutationResolvers['disconnectSocket'] = async (
if (!disconnectingSocket) {
// this happens a lot on server restart in dev mode
if (!__PRODUCTION__) return {user}
console.log('disconnectSocket error', socketId, userPresence)
throw new Error('Called disconnect without a valid socket')
}
await redis.lrem(`presence:${userId}`, 0, disconnectingSocket)
Expand Down
1 change: 1 addition & 0 deletions packages/server/socketHandlers/handleConnect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ const handleConnect = async (connectionContext: ConnectionContext) => {
connectionContext.ready()
return null
}
console.log('handleConnect calling publish', INSTANCE_ID, socketId)
const result = await publishInternalGQL<{data: {connectSocket: {tms: string[]}}}>({
authToken,
ip,
Expand Down
1 change: 1 addition & 0 deletions packages/server/socketHandlers/handleDisconnect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const handleDisconnect = async (connectionContext: ConnectionContext, options: O
relayUnsubscribeAll(connectionContext)
if (authToken.rol !== 'impersonate') {
const userId = getUserId(authToken)
console.log('handleDisconnect calling publish', socketId)
await publishInternalGQL({authToken, ip, query: disconnectQuery, socketId, variables: {userId}})
}
activeClients.delete(connectionContext.id)
Expand Down

0 comments on commit fcf7ab6

Please sign in to comment.