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 handling #12

Closed
gitrojones opened this issue May 30, 2024 · 2 comments
Closed

Subscription error handling #12

gitrojones opened this issue May 30, 2024 · 2 comments

Comments

@gitrojones
Copy link

Hello,

Here's a fork with reproduction of the subscription issue I was running into involving error handling.

Setup:

  1. Setup .env, replacing DATABASE_URL with your own
  2. Run the server via yarn serve (Assumes Node20)

Steps:

  1. Create a subscription in Ruru for Foo
  foo(fooId: $fooId) {
    event
  }
}
--- VARIABLES
{
  "fooId": 1
}

Expectations:
The error that is thrown in the subscribePlan should be routed to the maskError where the error can be handled/sanitized like in queries and mutations.

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

image

Why is this a bug?
An internal error is unhandled leading to the socket error.

Thanks!

@benjie
Copy link
Owner

benjie commented Jun 4, 2024

Reproduced with

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

@benjie
Copy link
Owner

benjie commented Jun 4, 2024

Closing in favour of graphile/crystal#2080

@benjie benjie closed this as completed Jun 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants