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

400 errors cause crash #51

Open
tonybroadbent opened this issue Aug 17, 2023 · 3 comments
Open

400 errors cause crash #51

tonybroadbent opened this issue Aug 17, 2023 · 3 comments

Comments

@tonybroadbent
Copy link

If the gql request fails with a code 400, nothing appears in the node-red debug log. Syslog contains something like:
Node-RED[372]: 17 Aug 12:39:22 - [info] [graphql:Get Octopus] undefined
Node-RED[372]: (node:372) UnhandledPromiseRejectionWarning: TypeError: Cannot set property 'graphql' of undefined
Node-RED[372]: at /home/pi/.node-red/node_modules/node-red-contrib-graphql/graphql.js:192:36
Node-RED[372]: at runMicrotasks ()
Node-RED[372]: at processTicksAndRejections (internal/process/task_queues.js:95:5)
Modifying line 192 in graph.js as below, and details of the problem are visible in the debugging output.
BEFORE: node.msg.payload.graphql = { error };
AFTER: node.msg = { payload: error };

@tonybroadbent
Copy link
Author

Yes, I think the "fix" for issue 32 has broken a few things around error handling. However, I've managed to learn gql and thereby fix my car charging problem, so many thanks for producing this great piece of code.

@rgstephens
Copy link
Owner

Thanks for reporting and troubleshooting this.

@tonybroadbent
Copy link
Author

Hi, I've completely reinstalled my RPI so clean install and I'm hitting this problem again.

2024-06-12T00:59:47.207241+01:00 raspberrypi Node-RED[1150870]: 12 Jun 00:59:47 - [error] TypeError: Cannot set properties of undefined (setting 'graphql')
2024-06-12T00:59:47.207401+01:00 raspberrypi Node-RED[1150870]:     at /home/pi/.node-red/node_modules/node-red-contrib-graphql/graphql.js:192:36
2024-06-12T00:59:47.207519+01:00 raspberrypi Node-RED[1150870]:     at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
2024-06-12T00:59:47.240438+01:00 raspberrypi systemd[1]: nodered.service: Main process exited, code=exited, status=1/FAILURE

Error causes the whole of node-red to restart.
My fix in callGraphQLServer was to initialise the payload:
node.msg.payload = {};
So the line below doesn't cause a crash if node.msg has no payload:
node.msg.payload.graphql = { error };
Cheers,
Tony

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