debug: add verbose WebSocket logging to terminal gateway

Need to see if handleConnection is even being called.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Vantz Stockwell 2026-03-13 14:27:43 -04:00
parent c4d7ad1833
commit 77a76262f5

View File

@ -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 });
}
});