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: no need to close the connection that is closing #10

Closed
wants to merge 2 commits into from

Conversation

bytemain
Copy link
Member

this._debug('close: already closed');
return;
}
this._ws.close(code, reason);

Choose a reason for hiding this comment

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

Copy link
Member Author

@bytemain bytemain Jun 29, 2024

Choose a reason for hiding this comment

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

Seems a little confusing to me, I think we actually did need to close the CONNECTING connection.

I think the error you say maybe happened on we close a CLOSING socket instead of a CONNECTING socket.

we can see the ws code, when we close the CONNECTING connection, the ws package will change its state to CLOSING, emit error and close event in the next tick.
image

for code in the master branch, when it receive error event, it will invoke _disconnect to close the original ws connection, but here the connection is already CLOSING or CLOSED, it may raise an error.

Copy link
Member Author

Choose a reason for hiding this comment

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

And I cannot understand why the process will exit, I will try to reproduce it.

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.

2 participants