Reputation: 33
I'm using firebase functions, it's great generally. Although the function below returns a response quickly, when I checked the GCP trace I saw the termination of that function usually takes 70-90 seconds. There is no other function that shows a similar termination time. Any idea, why does this happen? Thanks!
gameServerRouter.post('/create', (req, res) => {
Logger.logSystem(req.url, false);
return Promise.resolve()
.then(() => {
res.send({ "ResultCode": 0 });
return Promise.resolve();
});
});
Upvotes: 0
Views: 52
Reputation: 3576
You need to return the response ultimately. The function won't terminate otherwise.
A solution would be:
return Promise.resolve()
.then(() => {
return res.send({ "ResultCode": 0 });
});
Notice that the then
method will return the response object which will be finally returned by the post function. A good practice would be to set relevant headers too.
Upvotes: 1