Skip to content

Server crashes on every calls when extension returns a promise #2038

@nick-keller

Description

@nick-keller

Intended outcome

Returning a promise in the method willSendResponse of an extension should be supported

Actual outcome

If the method willSendResponse returns a promise or is async the server crashes on every calls and the client receives the errors: [{"message": "Cannot read property 'errors' of undefined"}]

How to reproduce the issue

Create a simple logging extension for an Apollo server 2:

const apolloServer = new ApolloServer({
  //...
  extensions: [ () => new Logger(), ],
})

And the logger:

export class Logger {
  async willSendResponse() {
    //...
  }
}

I'm assuming this is unintended and this sould be an easy fix ;)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions