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

Ignore node network errors after opening client socket #220

Merged
merged 2 commits into from
Mar 7, 2018
Merged

Conversation

mtharrison
Copy link
Contributor

This is another stab at fixing High Sierra tests for nes.

Since ws 3.3.3, node net.Socket errors are reemitted by ws. We aren't really interested in these events, since they are not emitted by browser implementations of websockets. What we're interested in in those cases is the close event which will be emitted by both browser and ws.

In our tests we close both server and websocket at the same time, meaning the server could close the TCP socket at the same time the client sends a close frame, which causes a ECONNRESET socket error. For some reason (timing difference?) this manifests in Mac OS X High Sierra by logging or throwing an error for each test. In some cases it just causes console noise. in other cases where no onerror is defined it will throw and cause the test to fail.

I brought this up on ws: websockets/ws#1316

The advice is to ignore net.Socket errors once the websocket is open, and in fact these won't even be emitted by ws in future versions. Doing so in nes and attaching onerror handlers for where we use raw ws in the tests fixes all the test issues AFAIK.

Closes #216

@mtharrison mtharrison added the bug Bug or defect label Mar 6, 2018
@mtharrison
Copy link
Contributor Author

mtharrison commented Mar 6, 2018

Guess I need a test for all the platforms that aren't behaving like Mac...

@@ -479,6 +479,7 @@ describe('Socket', () => {

await server.start();
const client = new Ws('http://localhost:' + server.info.port);
client.onerror = Hoek.ignore;
Copy link
Member

Choose a reason for hiding this comment

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

Are these still necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, if there's no error handler attached it will throw a read ECONNRESET error.

Copy link
Member

@devinivy devinivy left a comment

Choose a reason for hiding this comment

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

👍 👌

@mtharrison mtharrison merged commit 4b5c89a into master Mar 7, 2018
@mtharrison mtharrison deleted the fix-hs2 branch March 7, 2018 02:23
@mtharrison mtharrison added this to the 7.0.4 milestone Mar 7, 2018
@mtharrison mtharrison self-assigned this Mar 11, 2018
@lock
Copy link

lock bot commented Jan 9, 2020

This thread has been automatically locked due to inactivity. Please open a new issue for related bugs or questions following the new issue template instructions.

@lock lock bot locked as resolved and limited conversation to collaborators Jan 9, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Bug or defect
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Tests fail when running npm test on Mac OS X (High Sierra)
2 participants