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: catch all socket errors #1752

Merged
merged 2 commits into from
Dec 4, 2023
Merged

fix: catch all socket errors #1752

merged 2 commits into from
Dec 4, 2023

Conversation

robertsLando
Copy link
Member

Fixes #1751

Copy link

codecov bot commented Nov 30, 2023

Codecov Report

Attention: 1 lines in your changes are missing coverage. Please review.

Comparison is base (de89c0d) 79.47% compared to head (3a95d9d) 79.45%.
Report is 1 commits behind head on main.

Files Patch % Lines
src/lib/client.ts 50.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1752      +/-   ##
==========================================
- Coverage   79.47%   79.45%   -0.02%     
==========================================
  Files          23       23              
  Lines        1403     1402       -1     
  Branches      329      329              
==========================================
- Hits         1115     1114       -1     
  Misses        209      209              
  Partials       79       79              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@robertsLando
Copy link
Member Author

robertsLando commented Nov 30, 2023

Apart from the comment I added I didn't found any reason why we are filtering errors to emit. The errors that could happen on connect are a lot and we will always miss some, this PR just ignores all errors that comes from browser Websocket (like it happened before as code in that case is always undefined, explained why here) and emits all errors that happen on nodejs sockets.

Tests are working but I would like to know if someone has a reason why those errors should be filtered. Note that actually we always setup a client.on('error') listener so that would not throw unhandled rejections:

client.on('error', () => {
/* Automatically set up client error handling */
})

cc @mcollina @vishnureddy17

src/lib/client.ts Outdated Show resolved Hide resolved
@robertsLando
Copy link
Member Author

@mcollina Kindly ping

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

lgtm

@robertsLando robertsLando merged commit a50e85c into main Dec 4, 2023
6 of 8 checks passed
@robertsLando robertsLando deleted the catch-socket-errors branch December 4, 2023 09:18
hardillb added a commit to hardillb/MQTT.js that referenced this pull request Dec 5, 2023
Backport to version that supports NodeJS 14
@hardillb hardillb mentioned this pull request Dec 5, 2023
robertsLando pushed a commit that referenced this pull request Dec 5, 2023
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.

No error thrown with WSS:// if TLS error
2 participants