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

apollo-server-core: properly re-throw serverWillStop exceptions #5653

Merged
merged 1 commit into from
Aug 25, 2021

Conversation

glasser
Copy link
Member

@glasser glasser commented Aug 25, 2021

If a serverWillStop callback (or gateway.stop()) invoked by
server.stop() throws, the behavior of server.stop() is now
consistent: the original call to server.stop() throws the error, and
any concurrent and subsequent calls to server.stop() throw the same
error.

Prior to Apollo Server v2.22.0, the original call threw the error and
the behavior of concurrent and subsequent calls was undefined (in
practice, it would call shutdown handlers a second time).

Apollo Server v2.22.0 intended to put these semantics into place where
all three kinds of calls would throw, but due to bugs, the original call
would return without error and concurrent calls would hang. (Subsequent
calls would correctly throw the error.)

In addition, errors thrown by the drainServer hook introduced in
Apollo Server v3.2.0 are now handled in the same way.

The bugs are:

  • The error just wasn't being rethrown after being saved
  • barrier.resolve() wasn't called so concurrent calls would hang
  • drainServer was not in the same try block as serverWillStop
  • There weren't tests

Fixes #5649.

If a `serverWillStop` callback (or `gateway.stop()`) invoked by
`server.stop()` throws, the behavior of `server.stop()` is now
consistent: the original call to `server.stop()` throws the error, and
any concurrent and subsequent calls to `server.stop()` throw the same
error.

Prior to Apollo Server v2.22.0, the original call threw the error and
the behavior of concurrent and subsequent calls was undefined (in
practice, it would call shutdown handlers a second time).

Apollo Server v2.22.0 intended to put these semantics into place where
all three kinds of calls would throw, but due to bugs, the original call
would return without error and concurrent calls would hang. (Subsequent
calls would correctly throw the error.)

In addition, errors thrown by the `drainServer` hook introduced in
Apollo Server v3.2.0 are now handled in the same way.

The bugs are:
- The error just wasn't being rethrown after being saved
- `barrier.resolve()` wasn't called so concurrent calls would hang
- `drainServer` was not in the same `try` block as `serverWillStop`
- There weren't tests

Fixes #5649.
@glasser glasser enabled auto-merge (squash) August 25, 2021 23:00
@glasser glasser merged commit 97dce98 into main Aug 25, 2021
@glasser glasser deleted the glasser/stop-throw branch August 25, 2021 23:03
@glasser glasser added 2021-08 size/small Estimated to take LESS THAN A DAY labels Aug 25, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 20, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
size/small Estimated to take LESS THAN A DAY
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Errors thrown by serverWillStop handlers aren't rethrown by stop()
1 participant