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

Make WebSocketServer#handleUpgrade() callback optional #1968

Closed
wants to merge 1 commit into from

Conversation

lpinca
Copy link
Member

@lpinca lpinca commented Nov 2, 2021

If the upgrade is successful and the callback argument is not
provided, then emit the 'connection' event.

Refs: #1966

If the upgrade is successful and the `callback` argument is not
provided, then emit the `'connection'` event.

Refs: #1966
@lpinca
Copy link
Member Author

lpinca commented Nov 2, 2021

I don't like this because the method behavior depends on the callback argument. Instead it should always or never emit the 'connection' event, regardless of whether the callback argument is given or not.

@sdrsdr
Copy link

sdrsdr commented Nov 2, 2021

Works for me! 😃 This implementation is better but deeper. I as "external" contributor was striving for minimal code impact with my approach.

@sdrsdr
Copy link

sdrsdr commented Nov 2, 2021

https://github.com/websockets/ws/blob/5b87c5191ddbdae974f553fa841270b7919ae10c/test/handleupgrade-default-cb.test.js this is a test case I've forgotten in my firts commit in my PR. You can use it to test your implementation also

@lpinca
Copy link
Member Author

lpinca commented Nov 2, 2021

https://github.com/websockets/ws/blob/5b87c5191ddbdae974f553fa841270b7919ae10c/test/handleupgrade-default-cb.test.js this is a test case I've forgotten in my firts commit in my PR. You can use it to test your implementation also

It's already covered by this change

upgrade: this.handleUpgrade.bind(this)
A lot of existing tests would fail if the 'connection' event is not emitted.

@lpinca
Copy link
Member Author

lpinca commented Nov 2, 2021

I will keep this open for a while to collect feedback. If no one will comment I will close it.

@sdrsdr
Copy link

sdrsdr commented Nov 2, 2021

If you publish new package version I can try update the TypeScript definitions at DefinitelyTyped

@sdrsdr
Copy link

sdrsdr commented Nov 11, 2021

What is the timeframe for this PR?

@lpinca
Copy link
Member Author

lpinca commented Nov 11, 2021

See #1968 (comment). Let's wait a few more days.

@lpinca
Copy link
Member Author

lpinca commented Nov 16, 2021

I'm closing this as per #1968 (comment).

@lpinca lpinca closed this Nov 16, 2021
@lpinca lpinca deleted the make/callback-optional branch November 16, 2021 19:09
@sdrsdr
Copy link

sdrsdr commented Nov 16, 2021

Closed but not merged? I'm not sure what's going on here!

@lpinca
Copy link
Member Author

lpinca commented Nov 17, 2021

Yes, aside from yours, there seems to be no interest in getting this merged.

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