Skip to content

fix(socket.io): improve close() function #5344

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

fantua
Copy link

@fantua fantua commented Apr 30, 2025

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

Current behavior

After #4971 the usage of the close() function has become confusing and sometimes misleading.

Since close() now returns a Promise, I would expect the httpServer to close when the promise is resolved. However, this is not the case.

await io.close();
// httpServer not closed yet

Also, in order to catch all possible errors, I need to use a mixed style of async/await and callbacks:

io.close(error => {
  if (error) {
    // error here
  }
}).catch(error => {
  // another error here
});

New behavior

await io.close();
// httpServer closed
io.close().catch(error => {
  // all errors here
});

@@ -15507,7 +15507,7 @@
}
},
"packages/engine.io": {
"version": "6.6.3",
"version": "6.6.4",
Copy link
Author

Choose a reason for hiding this comment

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

related to 72d61da

@fantua fantua marked this pull request as ready for review April 30, 2025 15:11
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.

1 participant