-
Notifications
You must be signed in to change notification settings - Fork 17
WebSocket: fix error object on connection error #373
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
Conversation
Codecov Report
@@ Coverage Diff @@
## 6-dev #373 +/- ##
=========================================
+ Coverage 96.7% 96.71% +<.01%
=========================================
Files 29 29
Lines 1427 1429 +2
=========================================
+ Hits 1380 1382 +2
Misses 47 47
Continue to review full report at Codecov.
|
src/protocols/websocket.js
Outdated
this.client.onerror = error => { | ||
const err = (error instanceof Error) && error || new Error(error); | ||
const err = error ? | ||
new Error(error.message || error) : new Error('Unexpected 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.
Don't we loose the stacktrace returned by Kuzzle?
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.
It will be fixed with https://jira.kaliop.net/browse/KZL-1001, nevermind
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.
Well, even if it will be fixed, I think your point is valid. I prefer to fix this now, even if it is redundant with a future task.
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.
@Aschen > fixed
Description
On a websocket connection error, the error thrown by the SDK has the following message:
[object Object]
This is because on a connection error,
ws
sends a complex object, but our error handler processes it as if it's a string.How to test it
Run this snippet:
Before this PR, this prints:
With this PR: