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

Null header value results in page crash #1781

Open
subhan-nadeem opened this issue Nov 7, 2024 · 2 comments
Open

Null header value results in page crash #1781

subhan-nadeem opened this issue Nov 7, 2024 · 2 comments

Comments

@subhan-nadeem
Copy link

subhan-nadeem commented Nov 7, 2024

Describe the bug

In GraphQL Mesh, faced internal crashes where API responses were crashing due Access-Control-Allow-Origin header being set with nil value by response server:

 "message": "TypeError: Cannot read properties of undefined (reading 'includes')\n    at /Users/<user>/Desktop/<project>/graphqlmesh/node_modules/@whatwg-node/node-fetch/cjs/Headers.js:238:37\n    at /Users/<user>/Desktop/<project>/graphqlmesh/node_modules/@whatwg-node/node-fetch/cjs/Headers.js:149:25\n    at Array.forEach (<anonymous>)\n    at PonyfillHeaders.forEach (/Users/<user>/Desktop/<project>/graphqlmesh/node_modules/@whatwg-node/node-fetch/cjs/Headers.js:148:38)\n    at PonyfillHeaders.[nodejs.util.inspect.custom] (/Users/<user>/Desktop/<project>/graphqlmesh/node_modules/@whatwg-node/node-fetch/cjs/Headers.js:233:14)\n    at formatValue (node:internal/util/inspect:806:19)\n    at formatProperty (node:internal/util/inspect:1946:11)\n    at formatRaw (node:internal/util/inspect:1055:9)\n    at formatValue (node:internal/util/inspect:841:10)\n    at Object.inspect (node:internal/util/inspect:365:10)\nThis is caused by either a bug in Node.js or incorrect usage of Node.js internals.\nPlease open an issue with this stack trace at https://github.com/nodejs/node/issues\n",

Root cause seems to be the fact that the library does not guard against nil header values here: https://github.com/ardatan/whatwg-node/blob/master/packages/node-fetch/src/Headers.ts#L266

Should be an easy fix hopefully?

To Reproduce Steps to reproduce the behavior:

  • Instantiate a mock server in GraphQL Mesh and set Access-Control-Allow-Origin to undefined/nil in response to a query

Environment:

@ardatan

@ardatan
Copy link
Owner

ardatan commented Nov 7, 2024

Could you create a reproduction on CodeSandbox? Thanks! 🙏

@ardatan
Copy link
Owner

ardatan commented Nov 11, 2024

I'd love to help you and learn more about your use case of GraphQL Mesh. If you give more information at least, we can try to reproduce by ourselves. Thanks!

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