firebase-tools icon indicating copy to clipboard operation
firebase-tools copied to clipboard

Function with long processing gets idle after 2 minutes and timeouts (Firebase Emulator only)

Open Corchoneitor opened this issue 3 years ago • 3 comments

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

image

And the json response to the user...

{
  "result": {
    "success": true
  }
}

Actual behavior

image

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.

Corchoneitor avatar Mar 30 '22 17:03 Corchoneitor

I experience the same issue with "firebase-tools": "9.3.0",

fvulich avatar Mar 31 '22 18:03 fvulich

Any update on this? Thanks.

Corchoneitor avatar May 04 '22 17:05 Corchoneitor

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

Corchoneitor avatar Aug 23 '22 16:08 Corchoneitor

Fixed by #5464

joehan avatar Feb 22 '23 23:02 joehan