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

Errors thrown by serverWillStop handlers aren't rethrown by stop() #5649

Closed
glasser opened this issue Aug 25, 2021 · 0 comments · Fixed by #5653
Closed

Errors thrown by serverWillStop handlers aren't rethrown by stop() #5649

glasser opened this issue Aug 25, 2021 · 0 comments · Fixed by #5653
Labels
size/small Estimated to take LESS THAN A DAY

Comments

@glasser
Copy link
Member

glasser commented Aug 25, 2021

If serverWillStop throws, the error gets saved into the internal state under stopError and future (or concurrent) calls to stop will throw it, but then stop() just returns instead of re-throwing stopError. Pretty sure this is basically just a typo.

glasser added a commit that referenced this issue Aug 25, 2021
If a `serverWillStop` callback invoked by `server.stop()` throws (or
`gateway.stop()`), then `server.stop()` now correctly throws that error
instead of returning.

This was a regression introduced in Apollo Server v2.22.0. (Between
v2.22 and this release, a second subsequent or concurrent call to
`server.stop()` would correctly throw the error, but not the original
call.)

Fixes #5649.
glasser added a commit that referenced this issue 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.
glasser added a commit that referenced this issue 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.
glasser added a commit that referenced this issue 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.
@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 a pull request may close this issue.

1 participant