cloud-functions-emulator
cloud-functions-emulator copied to clipboard
Can't determine the issue based on error output
I'm running the emulator and my code seems to be running successfully, all the way up to the point of getting a Buffer
and assigning it as a reply.
The code that sends things back is found here. In my testing, I'm definitely able to get up to this point, but even if I put a plain string
message in there, I still get this same error:
{
"error": {
"code": 500,
"status": "INTERNAL",
"message": "function crashed",
"errors": [
"Parse Error"
]
}
}
Something is getting tripped up no matter what I put in that .send
callback.
While I'm okay with assuming that something in my response might be bad, the generic message of "Parse Error" really doesn't give me anything to go off of.
Any chance I can get this deciphered for me, and then beyond that, any chance of improving error output? Really if I can't get clarity when using a local emulator, I'm not inclined to target any production environment.
Can you please provide reproduction steps with which I can reproduction steps? Without those I can't really debug this for you.
Check out this repository: https://github.com/atrauzzi/protoculture-google-cloud-functions
Quick update: It's a bit involved, but run these commands in order from the demo
directory:
tsc
functions start
clear
functions deploy protoculture --trigger-http
I think to access, it's just a matter of going to: http://localhost:8010/blah/us-central1/protoculture
I followed your steps, and I got:
ERROR: Error: Node.js module defined by file index.js is expected to export function named protoculture
After inspecting the index.js
generated by the tsc
command, I don't see any exported function named protoculture
.
Is there any way to improve the error output to indicate this? I never end up seeing that error anywhere.
Are you sure I need to name the function in my export? The cloud functions docs make it seem like so long as I export a function, it will see it?
The Emulator expects a named function. Can you point me to the Cloud Functions docs where they make it seem like you can export just a function? If that's valid behavior then I need to update the Emulator.
As far as why you didn't see that error output, I have no idea. That's something I wasn't able to reproduce. Are you on Windows?
I recommend you export a named function.
Yeah, I'm on Windows.
Here's the doc: https://cloud.google.com/functions/docs/writing/
Specifically this part:
I can see the confusion, it appears that "exports one or more functions" is ambiguous. I will update those docs to say "exports one or more functions via named exports".
That would be awesome, thank you! :)