Skip to content

Commit

Permalink
apollo-server-core: properly re-throw serverWillStop exceptions
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
glasser committed Aug 25, 2021
1 parent 97984e7 commit 24c31d9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ The version headers in this history reflect the versions of Apollo Server itself

## vNEXT

## v3.3.0

- `apollo-server-core`: 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.) [Issue #5649](https://github.com/apollographql/apollo-server/issues/5649) [PR #5653](https://github.com/apollographql/apollo-server/pull/5653)

## v3.2.0

**If you're using `apollo-server-express` or another framework integration**, we highly recommend that you enable the new graceful shutdown feature after upgrading to 3.2.0. See the docs for [`ApolloServerPluginDrainHttpServer`](https://www.apollographql.com/docs/apollo-server/api/plugin/drain-http-server/) or the [basic usage for your integration of choice](https://www.apollographql.com/docs/apollo-server/integrations/middleware/#basic-usage).
Expand Down
2 changes: 1 addition & 1 deletion packages/apollo-server-core/src/ApolloServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -745,7 +745,7 @@ export class ApolloServerBase<
await Promise.all([...this.toDisposeLast].map((dispose) => dispose()));
} catch (stopError) {
this.state = { phase: 'stopped', stopError };
return;
throw stopError;
}
this.state = { phase: 'stopped', stopError: null };
}
Expand Down

0 comments on commit 24c31d9

Please sign in to comment.