Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign upStop sockjs from multiplying on reconnect #888
Conversation
Have you ever noticed when developing that every time you stop and start the server, the terminal window gets an extra duplicate line for every reconnect attempt? Well, it's because (I think) "delete" in javascript just removes the indicated name from the namespace, it doesn't actually free up an object. Those zombie objects are still there and wake up (for some transports) on reconnect. Might be different in SockJS v1 or later.
This comment has been minimized.
This comment has been minimized.
foosel
commented on src/octoprint/static/js/app/dataupdater.js in 91bdffa
May 11, 2015
|
Magic number? Where does that come from? |
This comment has been minimized.
This comment has been minimized.
|
Sockjs sources. They used a magic number too, no define or docs that I could find. It means from a direct call to close in v0.3.4. Probably we should define our own. It'll give back whatever we pass to close. But still weird since sockjs could still stomp on it with the same value used internally. |
This comment has been minimized.
This comment has been minimized.
foosel
replied
May 11, 2015
|
Let me just say "ewww" |
This comment has been minimized.
This comment has been minimized.
|
Yes I have seen the terminal lines get duplicated, then triplicated, etc. On 11 May 2015 at 03:03, Mark Walker notifications@github.com wrote:
|
This comment has been minimized.
This comment has been minimized.
|
OK, https://developer.mozilla.org/en-US/docs/Web/API/CloseEvent defines it as CLOSE_NORMAL, but sockjs just says 1000 in their source. But also, they reserve 4000-4999 for application defined. So which way do you want to go? Use 1000 because that's the MDN defined CLOSE_NORMAL? We could define it here since sockjs doesn't yet. Or make up our own? var OCTOPRINT_CLOSE_NORMAL = 4000 |
See https://developer.mozilla.org/en-US/docs/Web/API/CloseEvent WebSocket defines 1000 as CLOSE_NORMAL, SockJS uses it without a name and doesn't provide one for us, so for now we define our own
markwal commentedMay 11, 2015
Have you ever noticed when developing that every time you stop and start
the server, the terminal window gets an extra duplicate line for every
reconnect attempt? Well, it's because (I think) "delete" in javascript
just removes the indicated name from the namespace, it doesn't actually
free up an object. Those zombie objects are still there and wake up (for
some transports) on reconnect. Might be different in SockJS v1 or later.
Anyway, this fixes it for me in Chrome.