-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Duplicate messages emitted after error in onmessage #563
Comments
This appears to be the 0.3.4 equivalent code, which updates the buffer position ahead of sending an event and does not suffer from duplicate messages after error: sockjs-client/lib/trans-receiver-xhr.js Lines 14 to 24 in 0c70698
|
This issue has been inactive for 30 days. It will be in closed in 5 days without any new activity. |
Discussion has been happening in #564; false no-activity. |
This issue has been inactive for 30 days. It will be in closed in 5 days without any new activity. |
False no-activity. Discussion is in #564; waiting for feedback from @brycekahle. |
Ping to keep open; #564 is still waiting for feedback from @brycekahle. |
Using xhr-streaming, xhr-polling, or jsonp-polling, if an error is raised in the socket.onmessage event handler, then the next time a message is received SockJS will replay the message that caused the error.
For example, message A is received and the client
onmessage
event handler throws an uncaught error; later, message B is received, andonmessage
is called again with message A.Repro repo: https://github.com/jcheng5/sockjs-error-test
The problem appears to be here:
sockjs-client/lib/transport/receiver/xhr.js
Lines 40 to 52 in 71876b3
When
this.emit('message', msg);
throws an exception,this.bufferPosition
doesn't get updated (third clause of the for-loop). If you updatethis.bufferPosition
before emitting the message, the problem goes away.The text was updated successfully, but these errors were encountered: