diff --git a/backend/src/terminal/terminal.gateway.ts b/backend/src/terminal/terminal.gateway.ts index 958d40f..f2e8a7b 100644 --- a/backend/src/terminal/terminal.gateway.ts +++ b/backend/src/terminal/terminal.gateway.ts @@ -16,19 +16,23 @@ export class TerminalGateway implements OnGatewayConnection, OnGatewayDisconnect ) {} handleConnection(client: any, req: any) { + this.logger.log(`[WS] handleConnection fired, req.url=${req?.url}, client.url=${client?.url}`); const user = this.wsAuth.validateClient(client, req); if (!user) { + this.logger.warn(`[WS] Auth failed — closing 4001`); client.close(4001, 'Unauthorized'); return; } this.clientSessions.set(client, []); - this.logger.log(`Terminal WS connected: ${user.email}`); + this.logger.log(`[WS] Terminal connected: ${user.email}`); client.on('message', async (raw: Buffer) => { try { const msg = JSON.parse(raw.toString()); + this.logger.log(`[WS] Message: ${msg.type} ${JSON.stringify(msg).substring(0, 200)}`); await this.handleMessage(client, msg); } catch (err: any) { + this.logger.error(`[WS] handleMessage error: ${err.message}\n${err.stack}`); this.send(client, { type: 'error', message: err.message }); } });