Description
Hello,
After updating to 2.22 (see PR #4981) and applying the recommendation in changelog to insert await server.start()
between server = new ApolloServer()
and server.applyMiddleware
we started observing that Apollo is now listetning to termination signals and stops handling in-flight requests by throwing:
{"errors": [{
"message": "Cannot execute GraphQL operations after the server has stopped.",
"extensions": {"code":"INTERNAL_SERVER_ERROR"}
}]}
We were already handling these signals and calling the express close
method (which does not abort in-flight requests but rather stops accepting new ones and waits for the others to finish).
My impression was that when using some middleware, like express, rather than the standalone apollo server these signals should not be handled by apollo itself? At least they were not prior to 2.22.x.
To work around this issue we explicitely set stopOnTerminationSignals: false
and it seems to have resolved it.
Some context: We are deploying to a K8S deployment which does a rolling update. After the new version has started k8s sends a termination signal to the old version. Upon receiving this signal we make the readiness probe fail to avoid new requests being routed but keep express up for some more time until the in-flight requests are finished (or a timeout is triggered).