handle /ws_debug/health in debugger and add request logging (#8426)
- Fix debugger HTTP health endpoint to also match /ws_debug/health (ingress forwards the full path, not just /health) - Add request logging to all three extra services (LSP, multiplayer, debugger) for HTTP and WebSocket ping/upgrade events Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1069,11 +1069,14 @@ const server = Bun.serve({
|
||||
|
||||
// Handle WebSocket upgrade with path-based routing
|
||||
if (server.upgrade(req, { data: { path } })) {
|
||||
logger.info(`WS upgrade: ${path}`)
|
||||
return undefined as unknown as Response
|
||||
}
|
||||
|
||||
logger.info(`HTTP ${req.method} ${path}`)
|
||||
|
||||
// Health check endpoint
|
||||
if (path === '/health') {
|
||||
if (path === '/health' || path === '/ws_debug/health') {
|
||||
return new Response(JSON.stringify({
|
||||
status: 'ok',
|
||||
service: 'debugger',
|
||||
@@ -1102,6 +1105,7 @@ const server = Bun.serve({
|
||||
|
||||
// Handle ping test — respond and close immediately
|
||||
if (path === '/ping') {
|
||||
logger.info(`WS ping test`)
|
||||
ws.send(JSON.stringify({ type: 'pong', service: 'debugger' }))
|
||||
ws.close()
|
||||
return
|
||||
|
||||
@@ -96,6 +96,7 @@ class HealthHandler(web.RequestHandler):
|
||||
self.set_header("Content-Type", "application/json")
|
||||
|
||||
def get(self):
|
||||
log.info("HTTP GET %s", self.request.uri)
|
||||
self.write(json.dumps({"status": "ok", "service": "lsp"}))
|
||||
|
||||
def options(self):
|
||||
@@ -104,6 +105,7 @@ class HealthHandler(web.RequestHandler):
|
||||
|
||||
class PingHandler(websocket.WebSocketHandler):
|
||||
def open(self):
|
||||
log.info("WS ping from %s", self.request.remote_ip)
|
||||
self.write_message(json.dumps({"type": "pong", "service": "lsp"}))
|
||||
self.close()
|
||||
|
||||
|
||||
@@ -122,6 +122,7 @@ const setupWSConnection = (conn, req, docName) => {
|
||||
}
|
||||
|
||||
const server = http.createServer((req, res) => {
|
||||
console.log(`[${new Date().toISOString()}] HTTP ${req.method} ${req.url} from=${req.socket.remoteAddress}`)
|
||||
if (req.url === '/' || req.url === '/health' || req.url === '/ws_mp/health') {
|
||||
res.writeHead(200, {
|
||||
'Content-Type': 'application/json',
|
||||
@@ -144,15 +145,16 @@ wss.on('connection', (ws, req) => {
|
||||
docName = docName.slice('ws_mp/'.length)
|
||||
}
|
||||
|
||||
const clientIp = req.socket.remoteAddress
|
||||
|
||||
// Handle ping test — respond and close immediately
|
||||
if (docName === '__ping__') {
|
||||
console.log(`[${new Date().toISOString()}] WS ping from=${clientIp}`)
|
||||
ws.send(JSON.stringify({ type: 'pong', service: 'multiplayer' }))
|
||||
ws.close()
|
||||
return
|
||||
}
|
||||
|
||||
const clientIp = req.socket.remoteAddress
|
||||
|
||||
console.log(`[${new Date().toISOString()}] CONNECT: doc="${docName}" from=${clientIp}`)
|
||||
|
||||
ws.on('close', () => {
|
||||
|
||||
Reference in New Issue
Block a user