apollo-server icon indicating copy to clipboard operation
apollo-server copied to clipboard

fix(promises): avoid unhandledRejection errors

Open valters opened this issue 5 months ago • 2 comments

when logger needs to access function context (e.g. like pino does need)

to fix we must properly bind logger .warn/.error method reference on promise when passing it into .catch()


Hi, this is a small bugfix. We have been seeing a GraphQL Gateway Node process crash with unhandledRejection error when server is under heavy load, couple times a quarter maybe.

Originally I pointed the finger to https://github.com/pinojs/pino/issues/1962 , but the solution is not there.

After discussion, we found potential culprit(s) here. Please review?

valters avatar Jun 08 '25 09:06 valters

@valters: Thank you for submitting a pull request! Before we can merge it, you'll need to sign the Apollo Contributor License Agreement here: https://contribute.apollographql.com/

apollo-cla avatar Jun 08 '25 09:06 apollo-cla

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

codesandbox-ci[bot] avatar Jun 08 '25 09:06 codesandbox-ci[bot]

✅ Docs preview has no changes

The preview was not built because there were no changes.

Build ID: aa34cdb104bc4b05c5ee6200

apollo-librarian[bot] avatar Jul 02 '25 23:07 apollo-librarian[bot]

Good catch!

glasser avatar Jul 03 '25 06:07 glasser