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

Cannot read properties of undefined (reading 'originalError') #6088

Closed
4 tasks
Flamefork opened this issue Oct 13, 2023 · 8 comments
Closed
4 tasks

Cannot read properties of undefined (reading 'originalError') #6088

Flamefork opened this issue Oct 13, 2023 · 8 comments
Assignees

Comments

@Flamefork
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

A real error being masked by an exception in graphql-yoga's result-processor if more than one source used.

Seems like the problem is caused by graphql-jit's own version of GraphQLError which could have (and having) undefined in extensions, while in a lot of places it is treated as non-nullable, as in graphql-js.

For some reason, this problem does not occur when only one source present.

#6059 looks like another instance of this bug, though the one I'm reporting reproduces with the latest mesh version, after the fix.

To Reproduce Steps to reproduce the behavior:

I've uploaded a gist inspired by @TomKlaverAH reproduction 🙏 :

https://gist.github.com/Flamefork/2f00268dfb31a2b27dca5c5fc1e1692d

You can run it in one go with docker using:

docker run -it --rm --entrypoint=/bin/bash node:18 -c 'curl -sL https://gist.github.com/Flamefork/2f00268dfb31a2b27dca5c5fc1e1692d/raw | bash -s'

Expected behavior

The scenario is intentionally erroneous, the problem is that the expected outcome of this erroneous request should be a proper error

HTTP/1.1 200 OK

{"errors": [
  {"message": "Variable \"$input\" got invalid value { bogus: \"Res\" }; Field value.text of required type String! was not provided."},
  {"message": "Variable \"$input\" got invalid value { bogus: \"Res\" }; Field \"bogus\" is not defined by type MutInput."}
]}

but instead mesh responds with a generic exception in a response processing code

HTTP/1.1 500 Internal Server Error

{"errors":[
  {"message":"Cannot read properties of undefined (reading 'originalError')"}
]}

(formatted responses a bit for readability)

@Flamefork
Copy link
Author

Also related: dotansimha/graphql-yoga#2967

@dpnova
Copy link
Contributor

dpnova commented Nov 27, 2023

I'm getting this with a swagger source behind mesh. Quite annoying as I end up getting a 500 from mesh, but the backend source worked fine.

@dpnova
Copy link
Contributor

dpnova commented Nov 28, 2023

@Flamefork have you found a workaround for this?

In my case the backend rest API is not erroring, so it seems the only error is happening in mesh.

I tried bumping to the versions in this one #6059 but I'm still seeing the same issue.

This happens with a single source for me.

@ardatan
Copy link
Owner

ardatan commented Nov 28, 2023

Thanks for the details but could you please create a reproduction on CodeSandbox or StackBlitz instead of Docker?

@dpnova
Copy link
Contributor

dpnova commented Nov 28, 2023

I've noticed other people with the same issue here: zalando-incubator/graphql-jit#234

@ardatan is there a way to just run without graphql-jit ?

@dxbrandon
Copy link

dxbrandon commented Dec 12, 2023

@ardatan I'm also running into issues where I'm receiving an undefined error for originalError. I reproduced a codesandbox here: https://codesandbox.io/p/sandbox/sad-poincare-lkhtjp

This is also my first time using codesandbox so hopefully there aren't any issues with the environment.

After running the command: yarn start, I opened postman and ran this somewhat invalid query:
Screenshot 2023-12-11 at 6 54 52 PM

Screenshot 2023-12-11 at 6 54 19 PM

Here's the request body that I ran:

{
    "operationName": "MyMutation",
    "query": "mutation MyMutation {update_test(input: {name: \" \"})}",
    "extensions": {}
}

Hopefully this helps resolve the issue.

@ardatan
Copy link
Owner

ardatan commented Jan 3, 2024

Unfortunately I am not able to reproduce it even if I installed the dependencies and updated the start script in package.json;
https://codesandbox.io/p/devbox/pedantic-shannon-h9tpgk?file=%2Fpackage.json%3A7%2C23

@ardatan
Copy link
Owner

ardatan commented Jan 3, 2024

Fixed in the upstream package;
dotansimha/graphql-yoga#3157

@ardatan ardatan closed this as completed Jan 3, 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

4 participants