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

correctly await async close on adapters #4971

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

Conversation

marknelissen
Copy link

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

The close of the server does not await the async close operations of the adapters like the MongoAdapter, leading to errors due to premature closing of the underlying connection.

New behavior

The close awaits the async operations on the adapters of the different namespaces. This allows to be sure that e.g. the Mongo connection can be safely disposed of.

Other information (e.g. related issues)

I've chose the Promise.allSettled to avoid being too disruptive, since the current synchronous implementation already disregards any errors the closing of the adapters might raise.

@darrachequesne
Copy link
Member

Hi! Thanks for the pull request 👍

In that case, do you think it would make sense to wait for the completion of this.httpServer.close() below too?

Reference: https://nodejs.org/api/http.html#serverclosecallback

@marknelissen
Copy link
Author

That is already what is done. The only way to wait for it, is to pass the callback function, which the current code already does. It is not an awaitable function, since it does not return a Promise.

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.

None yet

2 participants