firebase-tools
firebase-tools copied to clipboard
Function with long processing gets idle after 2 minutes and timeouts (Firebase Emulator only)
Environment info
firebase-tools: 10.1.5
Platform: Windows
Node: 12.21.0
Test case
Problem occurs only in Firebase emulator with functions that take more than 120 seconds of processing. I have an onCall function which I run with timeoutSeconds 180 seconds. In this function, I do processing for over 130 seconds. After the process is done, the function doesn't return any result and also doesn't finish. Therefore, it gets "idle" until the timeout (180 seconds) is reached and then throws the timeout error. Then the user who did the call doesn't get any response.
Steps to reproduce
exports.setTestEnvironment = functions
.runWith({
timeoutSeconds: 180,
})
.https.onCall(async (data: any, context: any) => {
try {
await new Promise(resolve => setTimeout(resolve, 130000)); // // Sleep for 130 seconds, simulating processing for test purposes.
console.log('Done. Should return success and finish execution');
return {
success: true,
};
} catch (error) {
throw new functions.https.HttpsError('invalid-argument', error.message);
}
});
Expected behavior

And the json response to the user...
{
"result": {
"success": true
}
}
Actual behavior

User gets "ERR_EMPTY_RESPONSE".
This error only happens with the Firebase Emulator, and I'm not able to test my app correctly. The function works fine when it's deployed. I have not encountered this issue in github nor stackoverflow, which should be very straight forward to get.
Feel free to ask any question or present any workaround.
Thanks.
I experience the same issue with "firebase-tools": "9.3.0",
Any update on this? Thanks.
For other needs, I upgraded these dependencies and now the problem is solved.
node: 14.18.0 firebase-tools: 11.8.0 firebase-functions: 3.22.0
Fixed by #5464