apollo-server-core: properly re-throw serverWillStop exceptions #5653
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
If a
serverWillStop
callback (orgateway.stop()
) invoked byserver.stop()
throws, the behavior ofserver.stop()
is nowconsistent: the original call to
server.stop()
throws the error, andany concurrent and subsequent calls to
server.stop()
throw the sameerror.
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 inApollo Server v3.2.0 are now handled in the same way.
The bugs are:
barrier.resolve()
wasn't called so concurrent calls would hangdrainServer
was not in the sametry
block asserverWillStop
Fixes #5649.