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

Conversation

jaganvarun059
Copy link

@jaganvarun059 jaganvarun059 commented Oct 14, 2024

Issue Summary:

  1. In Strophe.js version 3.0.1, the Strophe.error method is unable to retrieve and process the stream error details.

  2. Currently, error details are only logged to the console instead of being handled.

  3. Previously, custom error handling could be implemented as follows:

Strophe.error = (errorMsg: string) => {
    // Custom error handling code
};

Fix Details:

  1. A call to Strophe.error(errorString) has been added in the _checkStreamError method immediately after logging the error to the console.
  2. This change enables the Strophe.error method override to capture stream error details, allowing custom error handling to function as expected.

Testing:

Verified that Strophe.error successfully captures and processes stream error details with the custom error handling code.

@jaganvarun059 jaganvarun059 changed the title Fix: Handle Stream Error Fix Stream Error Handling in Strophe v3.0.1 Nov 6, 2024
@@ -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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants