diff --git a/backend-nest/src/gateways/nats-bridge.gateway.ts b/backend-nest/src/gateways/nats-bridge.gateway.ts index 045c584..461f992 100644 --- a/backend-nest/src/gateways/nats-bridge.gateway.ts +++ b/backend-nest/src/gateways/nats-bridge.gateway.ts @@ -71,7 +71,10 @@ export class NatsBridgeGateway implements OnGatewayConnection, OnGatewayDisconne // Subscribe to NATS events for this license const listener = (event: string, data: unknown) => { - if (client.readyState === WebSocket.OPEN) { + // client.OPEN (instance constant) — NOT WebSocket.OPEN: with + // esModuleInterop off, the default `ws` import is undefined at + // runtime, so the static crashes. The instance constant is safe. + if (client.readyState === client.OPEN) { client.send(JSON.stringify({ type: 'event', license_id: payload.license_id, diff --git a/backend-nest/src/modules/console/console.gateway.ts b/backend-nest/src/modules/console/console.gateway.ts index 43b2fa7..34e2ed5 100644 --- a/backend-nest/src/modules/console/console.gateway.ts +++ b/backend-nest/src/modules/console/console.gateway.ts @@ -108,7 +108,9 @@ export class ConsoleGateway implements OnGatewayConnection, OnGatewayDisconnect const message = JSON.stringify({ event, data }); for (const client of clients) { - if (client.readyState === WebSocket.OPEN) { + // client.OPEN, not WebSocket.OPEN — esModuleInterop is off so the + // default `ws` import is undefined at runtime (would crash on forward). + if (client.readyState === client.OPEN) { client.send(message); } }