Open jesstelford opened 6 years ago
Thanks a lot for sharing your insights, @jesstelford. I'd be very curious to see if this is the underlying issue for the many reports about the "Function returned invalid status code: 0. Raw body: Server responded with 500" error 🙂
Let me know if I can help in any other way 👍
This relates to issues: #482, #442, https://github.com/graphcool/prisma/issues/1265, and probably others.
Any errors thrown in top-level code of a function cause cryptic error messages such as:
Function returned invalid status code: 0. Raw body: Server responded with 500
, orNo content to map due to end-of-input at [Source: ; line: 1, column: 0]
What works
This correctly shows an error in
graphcool logs
What doesn't work
This does not show a useful error
Suggested Fix
When loading the function source into node, catch errors then, not just when the function itself is executed.
I was unable to find where the code is that handles this part, unfortunately. So in lieu of a PR, here is a workaround:
The workaround
Wrap all your code outside the function in a
try/catch
, then only throw the error once inside the function: