fix more bugbot cleanup comments

This commit is contained in:
Vikhyath Mondreti
2026-01-29 19:01:32 -08:00
parent df1a951e98
commit 2b248104e6
3 changed files with 10 additions and 6 deletions

View File

@@ -20,6 +20,6 @@ export async function POST() {
return NextResponse.json({ token: response.token })
} catch {
return NextResponse.json({ error: 'Authentication required' }, { status: 401 })
return NextResponse.json({ error: 'Failed to generate token' }, { status: 500 })
}
}

View File

@@ -208,7 +208,11 @@ export function SocketProvider({ children, user }: SocketProviderProps) {
cb({ token: freshToken })
} catch (error) {
logger.error('Failed to generate fresh token for connection:', error)
cb({ token: null })
if (error instanceof Error && error.message === 'Authentication required') {
// True auth failure - pass null token, server will reject with "Authentication required"
cb({ token: null })
}
// For server errors, don't call cb - connection will timeout and Socket.IO will retry
}
},
})

View File

@@ -60,6 +60,7 @@ export function setupWorkflowHandlers(socket: AuthenticatedSocket, roomManager:
`Cleaning up socket ${existingUser.socketId} for user ${userId} (${isSameTab ? 'same tab' : 'stale'})`
)
await roomManager.removeUserFromRoom(existingUser.socketId)
roomManager.io.in(existingUser.socketId).socketsLeave(workflowId)
}
}
}
@@ -124,10 +125,9 @@ export function setupWorkflowHandlers(socket: AuthenticatedSocket, roomManager:
)
} catch (error) {
logger.error('Error joining workflow:', error)
socket.emit('error', {
type: 'JOIN_ERROR',
message: 'Failed to join workflow',
})
// Undo socket.join if addUserToRoom or subsequent operations failed
socket.leave(workflowId)
socket.emit('join-workflow-error', { error: 'Failed to join workflow' })
}
})