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

Await graphql handler to avoid unhandled promise rejections #123

Merged
merged 1 commit into from
Feb 6, 2024

Conversation

shawnmcknight
Copy link
Member

@shawnmcknight shawnmcknight commented Feb 5, 2024

There are scenarios where the graphqlHandler function can reject. Notably, I have seen this when supplying an improperly formatted multipart request (e.g. invalid json). However, because the call to the graphql handler is not awaited, the catch which handles the error will not be invoked. Instead, this error will bubble out to moleculer-web which does not properly handle the rejected promise. This leads to an unhandled promise rejection in Node and, depending on node version, a hard failure of the NodeJS process.

The solution is to simply await the execution of the graphql handler. In this case, if the handler rejects, then the catch will be properly invoked and there will not be an unhandled promise rejection.

Copy link
Member

@icebob icebob left a comment

Choose a reason for hiding this comment

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

Thanks!

@icebob icebob merged commit f25fe16 into moleculerjs:master Feb 6, 2024
5 checks passed
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.

3 participants