Skip to content

Conversation

valters
Copy link
Contributor

@valters valters commented Jun 8, 2025

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 pinojs/pino#1962 , but the solution is not there.

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

@apollo-cla
Copy link

@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/

Copy link

codesandbox-ci bot commented Jun 8, 2025

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.

@glasser glasser force-pushed the bind-logger-ref-1 branch from f4e7beb to 8d6d7a9 Compare July 2, 2025 23:40
@apollo-librarian
Copy link

apollo-librarian bot commented Jul 2, 2025

✅ Docs preview has no changes

The preview was not built because there were no changes.

Build ID: aa34cdb104bc4b05c5ee6200

valters and others added 2 commits July 2, 2025 23:31
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()
@glasser glasser force-pushed the bind-logger-ref-1 branch from 8d6d7a9 to 0c3b044 Compare July 3, 2025 06:31
@glasser glasser merged commit 5b26558 into apollographql:main Jul 3, 2025
17 of 18 checks passed
@glasser
Copy link
Member

glasser commented Jul 3, 2025

Good catch!

@github-actions github-actions bot mentioned this pull request Jul 3, 2025
glasser added a commit that referenced this pull request Jul 7, 2025
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to main, this PR will
be updated.

⚠️⚠️⚠️⚠️⚠️⚠️

`main` is currently in **pre mode** so this branch has prereleases
rather than normal releases. If you want to exit prereleases, run
`changeset pre exit` on `main`.

⚠️⚠️⚠️⚠️⚠️⚠️

# Releases
## @apollo/server-gateway-interface@2.0.0-rc.0

### Major Changes

- [#7515](#7515)
[`100233a`](100233a)
Thanks [@trevor-scheer](https://github.com/trevor-scheer)! - Drop
support for Node.JS v14, v16, and v20.

## @apollo/server-integration-testsuite@5.0.0-rc.0

### Major Changes

- [#7515](#7515)
[`100233a`](100233a)
Thanks [@trevor-scheer](https://github.com/trevor-scheer)! - Drop
support for Node.JS v14, v16, and v20.

### Patch Changes

- [#8078](#8078)
[`dabe7ba`](dabe7ba)
Thanks [@renovate](https://github.com/apps/renovate)! - Support Jest v30
as well as Jest v29.

- Updated dependencies
\[[`5b26558`](5b26558),
[`100233a`](100233a),
[`100233a`](100233a),
[`100233a`](100233a),
[`100233a`](100233a)]:
    -   @apollo/server@5.0.0-rc.0

## @apollo/server-plugin-response-cache@5.0.0-rc.0

### Major Changes

- [#7515](#7515)
[`100233a`](100233a)
Thanks [@trevor-scheer](https://github.com/trevor-scheer)! - Drop
support for Node.JS v14, v16, and v20.

### Patch Changes

- [#8076](#8076)
[`5b26558`](5b26558)
Thanks [@valters](https://github.com/valters)! - Fix some error logs to
properly call `logger.error` or `logger.warn` with `this` set. This
fixes errors or crashes from logger implementations that expect `this`
to be set properly in their methods.

- Updated dependencies
\[[`5b26558`](5b26558),
[`100233a`](100233a),
[`100233a`](100233a),
[`100233a`](100233a),
[`100233a`](100233a)]:
    -   @apollo/server@5.0.0-rc.0

## @apollo/server@5.0.0-rc.0

### Major Changes

- [#7515](#7515)
[`100233a`](100233a)
Thanks [@trevor-scheer](https://github.com/trevor-scheer)! - Drop
support for Node.JS v14, v16, and v20.

- [#7515](#7515)
[`100233a`](100233a)
Thanks [@trevor-scheer](https://github.com/trevor-scheer)! - Remove
`precomputedNonce` landing page configuration option

This option was introduced and subsequently deprecated in v4. Removing
this configuration in v4 is strictly an improvement to the security of
your landing page, and no longer exists in v5.

- [#7515](#7515)
[`100233a`](100233a)
Thanks [@trevor-scheer](https://github.com/trevor-scheer)! - Remove
`status400ForVariableCoercionErrors` configuration option; this
regression mitigation is now the default behavior in Apollo Server v5.

### Patch Changes

- [#8076](#8076)
[`5b26558`](5b26558)
Thanks [@valters](https://github.com/valters)! - Fix some error logs to
properly call `logger.error` or `logger.warn` with `this` set. This
fixes errors or crashes from logger implementations that expect `this`
to be set properly in their methods.

- [#7515](#7515)
[`100233a`](100233a)
Thanks [@trevor-scheer](https://github.com/trevor-scheer)! -
ApolloServerPluginSubscriptionCallback now takes a `fetcher` argument,
like the usage and schema reporting plugins. The default value is Node's
built-in fetch.

- Updated dependencies
\[[`100233a`](100233a)]:
    -   @apollo/server-gateway-interface@2.0.0-rc.0

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: David Glasser <glasser@davidglasser.net>
@github-actions github-actions bot mentioned this pull request Jul 16, 2025
glasser added a commit that referenced this pull request Jul 17, 2025
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to main, this PR will
be updated.


# Releases
## @apollo/server-gateway-interface@2.0.0

### Major Changes

- [#7515](#7515)
[`100233a`](100233a)
Thanks [@trevor-scheer](https://github.com/trevor-scheer)! - Drop
support for Node.JS v14, v16, and v20.

## @apollo/server-integration-testsuite@5.0.0

### Major Changes

- [#7515](#7515)
[`100233a`](100233a)
Thanks [@trevor-scheer](https://github.com/trevor-scheer)! - Drop
support for Node.JS v14, v16, and v20.

### Patch Changes

- [#8078](#8078)
[`dabe7ba`](dabe7ba)
Thanks [@renovate](https://github.com/apps/renovate)! - Support Jest v30
as well as Jest v29.

- Updated dependencies
\[[`5b26558`](5b26558),
[`100233a`](100233a),
[`100233a`](100233a),
[`100233a`](100233a),
[`100233a`](100233a)]:
    -   @apollo/server@5.0.0

## @apollo/server-plugin-response-cache@5.0.0

### Major Changes

- [#7515](#7515)
[`100233a`](100233a)
Thanks [@trevor-scheer](https://github.com/trevor-scheer)! - Drop
support for Node.JS v14, v16, and v20.

### Patch Changes

- [#8076](#8076)
[`5b26558`](5b26558)
Thanks [@valters](https://github.com/valters)! - Fix some error logs to
properly call `logger.error` or `logger.warn` with `this` set. This
fixes errors or crashes from logger implementations that expect `this`
to be set properly in their methods.

## @apollo/server@5.0.0

### Major Changes

- [#7515](#7515)
[`100233a`](100233a)
Thanks [@trevor-scheer](https://github.com/trevor-scheer)! - Drop
support for Node.JS v14, v16, and v20.

- [#7515](#7515)
[`100233a`](100233a)
Thanks [@trevor-scheer](https://github.com/trevor-scheer)! - Remove
`precomputedNonce` landing page configuration option

This option was introduced and subsequently deprecated in v4. Removing
this configuration in v4 is strictly an improvement to the security of
your landing page, and no longer exists in v5.

- [#7515](#7515)
[`100233a`](100233a)
Thanks [@trevor-scheer](https://github.com/trevor-scheer)! - Remove
`status400ForVariableCoercionErrors` configuration option; this
regression mitigation is now the default behavior in Apollo Server v5.

### Patch Changes

- [#8076](#8076)
[`5b26558`](5b26558)
Thanks [@valters](https://github.com/valters)! - Fix some error logs to
properly call `logger.error` or `logger.warn` with `this` set. This
fixes errors or crashes from logger implementations that expect `this`
to be set properly in their methods.

- [#7515](#7515)
[`100233a`](100233a)
Thanks [@trevor-scheer](https://github.com/trevor-scheer)! -
ApolloServerPluginSubscriptionCallback now takes a `fetcher` argument,
like the usage and schema reporting plugins. The default value is Node's
built-in fetch.

- Updated dependencies
\[[`100233a`](100233a)]:
    -   @apollo/server-gateway-interface@2.0.0

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: David Glasser <glasser@davidglasser.net>
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 3, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants