glasser / apollo-server-race-condition

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

This repo can be used to reproduce the conditions that appear to sometimes trigger the unhandled promise rejection described in this issue:

apollographql/apollo-server#4472

To Run

  1. Run npm install
  2. Run npm run start
  3. Run ./curl.sh

You should see the following error logged by orphanedRequestPlugin.js in your server logs:

{
  msg: 'willResolveField called after willSendResponse',
  stack: 'Error\n' +
...

What's the Problem?

The fact that willResolveField() is called after willSendResponse() isn't necessarily a problem. It's that when this happens in Apollo's ApolloServerPluginUsageReporting plugin, the traceTreeBuilder code below throws an error when willResolveField() is called after the response has already been sent:

  public willResolveField(info: GraphQLResolveInfo): () => void {
  ...
    
  if (this.stopped) {
    throw internalError('willResolveField called after stopTiming!');
  }

It's unclear why the code above results in an unhandled promise rejection in some scenarios and not others.

About


Languages

Language:JavaScript 91.8%Language:Shell 8.2%