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

Don't delete ws when closing the server #444

Merged
merged 2 commits into from
Nov 15, 2016
Merged

Don't delete ws when closing the server #444

merged 2 commits into from
Nov 15, 2016

Conversation

perrin4869
Copy link
Contributor

The kind of change this PR does introduce

  • a bug fix
  • a new feature
  • an update to the documentation
  • a code change that improves performance
  • other

Fixes #442
Maybe a test to protect from regressions should be added, similar to what @veloce48 did in the original issue at the end.

@darrachequesne
Copy link
Member

@perrin4869 thanks! Can you indeed add the test you're suggesting please?

@@ -191,7 +191,7 @@ Server.prototype.close = function () {
if (this.ws) {
debug('closing webSocketServer');
this.ws.close();
delete this.ws;
// don't delete this.ws because it can be used again if the server starts listening again
Copy link
Member

Choose a reason for hiding this comment

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

I understand the purpose here, but won't the comment seem a bit weird since the line delete this.ws; will be deleted?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah it's there in order for people not to add it again in the future, and give the reasoning why.
I tend to add this kind of comments since sometimes I forget the reason I removed a certain line and saves me the time in trying it again, but of course it can be removed. It'll be a bit redundant if we manage to test this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

At the end of the day, I think that, since deleting this.ws is such a tempting thing to do, the comment might help future contributors understand why we can't do it, and will save them time it would take them to figure it out on their own.

@perrin4869
Copy link
Contributor Author

I could try to add the test, but I am not very well acquainted with engine.io, I'm more familiar with socket.io, and the test suggested used socket.io.

@perrin4869
Copy link
Contributor Author

Managed to add a test to prevent regression :)

@perrin4869
Copy link
Contributor Author

Maybe a similar test should be added to socket.io

@darrachequesne darrachequesne merged commit 7f659a5 into socketio:master Nov 15, 2016
@darrachequesne
Copy link
Member

@perrin4869 thanks!

@darrachequesne darrachequesne added this to the 1.8.0 milestone Nov 20, 2016
darrachequesne pushed a commit that referenced this pull request May 8, 2020
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.

Uncaught TypeError: Cannot read property 'handleUpgrade' of undefined
2 participants