Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
Corchoneitor opened this issue Mar 30, 2022 · 4 comments

Comments

@Corchoneitor
Copy link

Corchoneitor commented Mar 30, 2022

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.

@fvulich
Copy link

fvulich commented Mar 31, 2022

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

@Corchoneitor
Copy link
Author

Any update on this? Thanks.

@Corchoneitor
Copy link
Author

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

@joehan
Copy link
Contributor

joehan commented Feb 22, 2023

Fixed by #5464

@joehan joehan closed this as completed Feb 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants