GCloud: Debug “function crashed out of request sco

2019-07-23 04:20发布

问题:

I'm running a GCloud function, which seems to crash silently, without any kind of error trace.

Everything works perfectly in the emulator but crashes when running on GCloud!

The following message shows up in the function's logs:

Error: function crashed out of request scope Function killed.

Any idea on how to debug this?

回答1:

I think this issue has to do with what you are returning, and how you returning it. In the production environment, if you do not properly return a promise your function will be killed since it assumes your work is done. locally, that will probably not happen so the bug is invisible. Look here, for an example: https://github.com/firebase/functions-samples/issues/78