Google Cloud Function Finishes Execution But Never Enters Callbacks

前端 未结 1 434
甜味超标
甜味超标 2021-01-17 04:17

I am trying to make ~25 requests to fetch some data and save the response to separate files. I am using the npm request module to make the requests with a basic google cloud

1条回答
  •  臣服心动
    2021-01-17 04:38

    I was able to resolve by updating to use Promise.all() and mapping the request calls to promise objects using new Promise. Returning Promise.all() to the main Google Cloud Function body let's the function know to wait for all promises to finish before exiting the function. Implementing callbacks instead of promises may cause the Google cloud function to exit prematurely before all callbacks are finished.

    0 讨论(0)
提交回复
热议问题