-
Notifications
You must be signed in to change notification settings - Fork 340
Emit event when an websocket error occurs. #341
Emit event when an websocket error occurs. #341
Conversation
@damour: Thank you for submitting a pull request! Before we can merge it, you'll need to sign the Meteor Contributor Agreement here: https://contribute.meteor.com/ |
519b3fb
to
6b505b2
Compare
Will this allow logging the errors with something like apollo-link-error? |
@tim-soft yes I guess so! Can this PR please taken care of? This is pretty important as right now there is no possibility to catch Websocket errors using the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is awesome! 😍
Two small nitpicks and a rebase and this would be ready to ship!
README.md
Outdated
@@ -255,7 +255,7 @@ ReactDOM.render( | |||
#### `unsubscribeAll() => void` - unsubscribes from all active subscriptions. | |||
|
|||
#### `on(eventName, callback, thisContext) => Function` | |||
- `eventName: string`: the name of the event, available events are: `connecting`, `connected`, `reconnecting`, `reconnected` and `disconnected` | |||
- `eventName: string`: the name of the event, available events are: `connecting`, `connected`, `reconnecting`, `reconnected`, `disconnected` and `websocket_error` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's call this event error
instead, no need to specify websocket
just like in the other events.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed.
README.md
Outdated
@@ -285,6 +285,11 @@ ReactDOM.render( | |||
- `thisContext: any`: `this` context to use when calling the callback function. | |||
- => Returns an `off` method to cancel the event subscription. | |||
|
|||
#### `onWebSocketError(callback, thisContext) => Function` - shorthand for `.on('websocket_error', ...)` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, no need for the WebSocket
, let's call this onError
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
6b505b2
to
1a3d0e6
Compare
1a3d0e6
to
c46c5d8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thank you!
…types/sinon-2.1.0 Update @types/sinon to the latest version 🚀
Use case:
Writing simple (load)testing tools. At that moment there is no simple way to determinate connection errors. Also useful to debug network troubles.
Could this be a plugin?
No, we can't subscribe to ws error event directly.
Is there a workaround?
Save connection state(to check that connection closed by server) and catch
disconnected
event. But we don't have any error details.