jakearchibald/wittr

Server crashes on websocket timeout

Goldob opened this issue · 1 comments

See title. The problem can be reproduced with the following steps:

  1. Run the server with npm run serve
  2. Visit http://localhost:8888 in the browser
  3. Reload or close the browser window

This results in an error being thrown by the server, which then stops responding to further requests.

Error: not opened
    at WebSocket.send (/home/goldob/Code/wittr/node_modules/ws/lib/WebSocket.js:218:16)
    at /home/goldob/Code/wittr/build/server/Server.js:236:23
    at Array.forEach (native)
    at Server._broadcast (/home/goldob/Code/wittr/build/server/Server.js:235:21)
    at Server._addMessage (/home/goldob/Code/wittr/build/server/Server.js:313:12)
    at Timeout._onTimeout (/home/goldob/Code/wittr/build/server/Server.js:227:16)
    at ontimeout (timers.js:386:14)
    at tryOnTimeout (timers.js:250:5)
    at Timer.listOnTimeout (timers.js:214:5)

I think I can manage to track the problem and submit a fix in short time, but still wanted to open this issue just for reference.