Skip to content

Commit df1a951

Browse files
committed
bugbot comment
1 parent 1fbe302 commit df1a951

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

apps/sim/socket/routes/http.ts

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,21 @@ interface Logger {
1717
export function createHttpHandler(roomManager: IRoomManager, logger: Logger) {
1818
return async (req: IncomingMessage, res: ServerResponse) => {
1919
if (req.method === 'GET' && req.url === '/health') {
20-
const connections = await roomManager.getTotalActiveConnections()
21-
res.writeHead(200, { 'Content-Type': 'application/json' })
22-
res.end(
23-
JSON.stringify({
24-
status: 'ok',
25-
timestamp: new Date().toISOString(),
26-
connections,
27-
})
28-
)
20+
try {
21+
const connections = await roomManager.getTotalActiveConnections()
22+
res.writeHead(200, { 'Content-Type': 'application/json' })
23+
res.end(
24+
JSON.stringify({
25+
status: 'ok',
26+
timestamp: new Date().toISOString(),
27+
connections,
28+
})
29+
)
30+
} catch (error) {
31+
logger.error('Error in health check:', error)
32+
res.writeHead(503, { 'Content-Type': 'application/json' })
33+
res.end(JSON.stringify({ status: 'error', message: 'Health check failed' }))
34+
}
2935
return
3036
}
3137

0 commit comments

Comments
 (0)