Skip to content
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

Fix Stream Error Handling in Strophe v3.0.1 #754

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/websocket.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ class Websocket {
errorString += ' - ' + text;
}
log.error(errorString);
// The stream error is sent to the Strophe error method, allowing it to be handled.
Strophe.error(errorString);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR. I understand the problem that you have, but this is not a proper fix.

The Strophe object isn't imported into this file (and shouldn't be to avoid circular dependencies) and you're relying on Strophe being a global here, which is not a guarantee.

For a proper fix, we'll need calls to log.error to somehow be surfaced towards the Strophe object so that they can be overridden or intercepted via Strophe.error.

I'm not sure right now what the right solution will be. Maybe the right solution is to just throw and event inside log.error (and log.info etc.) which is caught by the Strophe object.


// close the connection on stream_error
this._conn._changeConnectStatus(connectstatus, condition);
Expand Down