Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Subscription error causes socket to disconnect #2080

Closed
benjie opened this issue Jun 4, 2024 · 0 comments · Fixed by #2081
Closed

Subscription error causes socket to disconnect #2080

benjie opened this issue Jun 4, 2024 · 0 comments · Fixed by #2081
Labels

Comments

@benjie
Copy link
Member

benjie commented Jun 4, 2024

Summary

Error thrown during subscription execution results in websocket connection terminating due to secondary unhandled error whilst trying to handle the first error. This is related to the reworking of errors in #2036 and related PRs.

Steps to reproduce

Plugin:

    makeExtendSchemaPlugin({
      typeDefs: gql`
        extend type Subscription {
          error: Int
        }
      `,
      plans: {
        Subscription: {
          error: {
            subscribePlan() {
              return lambda(constant(3), () => {
                throw new Error("Testing error");
              });
            },
          },
        },
      },
    })

GraphQL request:

subscription {
  error
}

Expected results

Error rendered in GraphiQL but socket connection not terminated.

Actual results

{
  "errors": [
    {
      "message": "Socket closed with event 4500 Cannot read properties of undefined (reading 'message')",
      "stack": "Error: Socket closed with event 4500 Cannot read properties of undefined (reading 'message')\n    at Object.error (http://127.0.0.1:5678/:49:1285975)\n    at http://127.0.0.1:5678/:49:474548"
    }
  ]
}

Additional context

Originally reported by @gitrojones in benjie/ouch-my-finger#12

The error is mishandled and throws an internal error instead. The handler is assuming originalError exists in grafast/prepare.js > output.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: ✅ Done
Development

Successfully merging a pull request may close this issue.

1 participant