disconnect startup error handler after establishing connection
This commit is contained in:
parent
272f5cc5ab
commit
4f68bbfd52
1 changed files with 9 additions and 5 deletions
|
|
@ -228,19 +228,23 @@ export class StreamingApiServerService implements OnApplicationShutdown {
|
|||
stream.dispose();
|
||||
});
|
||||
|
||||
ws.once('error', (e) => {
|
||||
this.#logger.error(`Unhandled error in Streaming Api: ${renderInlineError(e)}`);
|
||||
ws.terminate();
|
||||
});
|
||||
|
||||
if (dieInstantly !== null) {
|
||||
ws.close(...dieInstantly);
|
||||
return;
|
||||
}
|
||||
|
||||
// Special handler to hard-terminate the connection if it fails during initialization.
|
||||
// Disconnect immediately after because the connection() handler below defines its own error handler.
|
||||
const onWsInitError = (error: unknown) => {
|
||||
this.onWsError(error);
|
||||
ws.terminate();
|
||||
};
|
||||
|
||||
ws.on('error', onWsInitError);
|
||||
this.#wss.emit('connection', ws, request, {
|
||||
stream, user, app,
|
||||
});
|
||||
ws.off('error', onWsInitError);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue