Description
Issue Description
When I define Cloud jobs as async
functions and make calls within those jobs using await
, Node.js doesn't actually wait for those calls to resolve; the function terminates prematurely.
Note that Cloud functions work just fine--all of my await calls properly resolve before the function terminates.
Looking through FunctionsRouter.js, it seems like jobs and functions get called using very different control structures. The fact that the exact same code behaves so differently in jobs vs functions leads me to believe that there is some sort of bug in how Parse Server is dispatching cloud jobs.
I am running these calls on AWS Lambda, which is aggressive about killing functions, but theoretically this could be a problem anywhere I think.
I first ran into this on Parse Server 2.8.2, I was hoping that 3.0.0 would fix it with its better support for async Cloud operations, but the problem persists.
Steps to reproduce
Take a look at my code snippet here: https://stackoverflow.com/questions/51832572/trouble-with-async-and-parse
Duplicate a version of that runs as a Cloud function rather than Cloud job. Observe
Environment Setup
- Server
- parse-server version (Be specific! Don't say 'latest'.) : 3.0.0
- AWS Lambda / Node.js 8.10