Skip to content

Commit

Permalink
Merge pull request #3002 from storybooks/fix-rn-ws
Browse files Browse the repository at this point in the history
RN: Add error handler on WS to fix crashing on page reload
  • Loading branch information
Hypnosphi authored Feb 20, 2018
2 parents 4741632 + dba45e5 commit 0404c7a
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions app/react-native/src/server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ export default class Server {
}
}

// see https://github.com/websockets/ws/issues/1256#issuecomment-364988689
socket.on('error', err => {
// Ignore network errors like `ECONNRESET`, `EPIPE`, etc.
if (err.errno) return;
throw err;
});

socket.on('message', data => {
this.wsServer.clients.forEach(c => {
if (!this.options.manualId || (socket.pairedId && socket.pairedId === c.pairedId)) {
Expand Down

0 comments on commit 0404c7a

Please sign in to comment.