Skip to content

Commit

Permalink
Gracefully stop publication and close WS
Browse files Browse the repository at this point in the history
  • Loading branch information
sampaiodiego committed Feb 22, 2023
1 parent 19afbac commit 69b6ae0
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions ee/apps/ddp-streamer/src/Streamer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ export class Stream extends Streamer {
// if the connection state is not open anymore, it somehow got to a weird state,
// we'll emit close so it can clean up the weird state, and so we stop emitting to it
if (subscription.client.ws.readyState !== WebSocket.OPEN) {
subscription.client.ws.emit('close');
subscription.stop();
subscription.client.ws.close();
continue;
}

Expand Down Expand Up @@ -89,7 +90,8 @@ export class Stream extends Streamer {

// if we still tried to send data to a destroyed stream, we'll try again to close the connection
if (subscription.client.ws.readyState !== WebSocket.OPEN) {
subscription.client.ws.emit('close');
subscription.stop();
subscription.client.ws.close();
}
}
console.error('Error trying to send data to stream.', error);
Expand Down

0 comments on commit 69b6ae0

Please sign in to comment.