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

GraphQL Handler - Crashes on Configuration Errors #5402

Closed
4 tasks
steve-gray opened this issue May 7, 2023 · 4 comments
Closed
4 tasks

GraphQL Handler - Crashes on Configuration Errors #5402

steve-gray opened this issue May 7, 2023 · 4 comments

Comments

@steve-gray
Copy link

Issue workflow progress

Progress of the issue based on the
Contributor Workflow

Make sure to fork this template and run yarn generate in the terminal.

Please make sure Mesh package versions under package.json matches yours.

  • 2. A failing test has been provided
  • 3. A local solution has been provided
  • 4. A pull request is pending review

Describe the bug

When using the WS transport for subscriptions in the GraphQL handler, any configuration error causes the instance to terminate.

To Reproduce Steps to reproduce the behavior:

  • Set up a GraphQL handler with a subscription, but use an endpoint that is interpolated (i.e. env.SOMEURL). Another bug/issue I'll report separately means this variable isn't being interpolated today.
  • Invoke the subscription.

The mesh instance will terminate with this trace:

/Users/steve/go/src/github.com/steve-gray/test-graph/node_modules/ws/lib/websocket.js:675
      throw new SyntaxError(`Invalid URL: ${address}`);
            ^
SyntaxError: Invalid URL: {env.TEST_URL}
    at initAsClient (/Users/steve/go/src/github.com/steve-gray/test-graph/node_modules/ws/lib/websocket.js:675:13)
    at new WebSocket (/Users/steve/go/src/github.com/steve-gray/test-graph/node_modules/ws/lib/websocket.js:85:7)
    at /Users/steve/go/src/github.com/steve-gray/test-graph/node_modules/graphql-ws/lib/client.js:158:28
    at /Users/steve/go/src/github.com/steve-gray/test-graph/node_modules/graphql-ws/lib/client.js:261:11
    at new Promise (<anonymous>)
    at connect (/Users/steve/go/src/github.com/steve-gray/test-graph/node_modules/graphql-ws/lib/client.js:147:121)
    at /Users/steve/go/src/github.com/steve-gray/test-graph/node_modules/graphql-ws/lib/client.js:373:87
    at Object.subscribe (/Users/steve/go/src/github.com/steve-gray/test-graph/node_modules/graphql-ws/lib/client.js:424:15)
    at Object.repeaterExecutor [as executor] (/Users/steve/go/src/github.com/steve-gray/test-graph/node_modules/@graphql-tools/executor-graphql-ws/cjs/index.js:33:53)
    at /Users/steve/go/src/github.com/steve-gray/test-graph/node_modules/@repeaterjs/repeater/cjs/repeater.js:453:69

Expected behavior

A runtime error (This is the behaviour in LEGACY_WS) that does not terminate the instance.

@steve-gray
Copy link
Author

It appears this crash occurs any time there's a non-clean socket disconnect too, in Kubernetes this leads to pod groups going into Crashloop due to:

image

@ardatan
Copy link
Owner

ardatan commented Jun 12, 2023

Fixed in e4f94eb

@ardatan ardatan closed this as completed Jun 12, 2023
@steve-gray
Copy link
Author

steve-gray commented Jun 12, 2023

The other issue is fixed, but this one isn't. The other issue was just how I found this one - but as per the above any non-clean disconnect causes an error.

The change needed here is to improve the error handling, to not cause the process to fail entirely.

@ardatan
Copy link
Owner

ardatan commented Jun 12, 2023

ardatan/graphql-tools#5349
Fixed in the underlying package. Thanks for the feedback.

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