Skip to content

Commit

Permalink
fix eclipse-theia#2933: don't send a message if a ws socket is closed
Browse files Browse the repository at this point in the history
Signed-off-by: Anton Kosyakov <anton.kosyakov@typefox.io>
  • Loading branch information
akosyakov committed Sep 21, 2018
1 parent 543b119 commit 41b4d63
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions packages/core/src/node/messaging/messaging-contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,15 @@ export class MessagingContribution implements BackendApplicationContribution, Me
}

protected createChannel(id: number, socket: ws): WebSocketChannel {
return new WebSocketChannel(id, content => socket.send(content, err => {
if (err) {
throw err;
return new WebSocketChannel(id, content => {
if (socket.readyState < ws.CLOSING) {
socket.send(content, err => {
if (err) {
throw err;
}
});
}
}));
});
}

}
Expand Down

0 comments on commit 41b4d63

Please sign in to comment.