firebase-tools: expose worker idle timeout options as per GCP emulator

Firebase functions currently timeout locally at 60 seconds, whereas this duration is configurable for remote executions.

GCP emulator provides the --idlePruneInterval and --maxIdle options for functions start, however these are currently not available from the firebase emulator cli.

see: https://github.com/GoogleCloudPlatform/cloud-functions-emulator/issues/66 also see: https://stackoverflow.com/questions/47897400/update-firebase-emulator-function-timeout-duration

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 1
  • Comments: 22 (10 by maintainers)

Commits related to this issue

Most upvoted comments

I was talking about exposing timeout option in emulation, if you’re talking about in deploying functions, then yes we do have plans to expose this in the future.

The latest firebase CLI release (v3.17.7) now sets maxIdle to 9 minutes for all emulated functions, that should hopefully fulfill your needs since emulated functions will no longer be timing out. We chose 9 min since that’s the max timeout of deployed functions. We chose to simply set the timeout instead of making it configurable for an easier user experience, since there’s no harm to have a longer timeout than you need for emulated functions, you can always quit the process by Ctrl + C

Hi @joemanfoo, thanks for bringing this to our attention! I can confirm that we are seeing the 60s timeout instead of 540s like we are supposed to. We’ve filed an internal bug, and will be looking into this.

Thanks for getting back to me, @laurenzlong. It appears that I’m still getting timed out after 1 minute even after I run npm i -g firebase-tools:

image

Is the .runWith(runtimeOptions) the appropriate way to indicate a longer execution time or should I be indicating this differently (e.g. a command line argument)?

Thanks for your time!

I’m not sure that those are the right options to affect this particular timeout. There’s actually a separate timeout option when one deploys a function, but currently firebase-tools doesn’t set it.

In addition, there’s currently a “functions proxy” timeout (also of 60s).

Both options should be set to a correct value to do the job. One can temporarily use patch-package to override them:

--- a/node_modules/firebase-tools/lib/functionsEmulator.js
+++ b/node_modules/firebase-tools/lib/functionsEmulator.js
@@ -133,7 +133,10 @@ FunctionsEmulator.prototype.start = function(shellMode) {
       if (trigger.httpsTrigger) {
         return controller.deploy(trigger.name, {
           localPath: functionsDir,
-          triggerHttp: true
+          triggerHttp: true,
+          timeout: {
+            seconds: 540,
+          },
         }).catch(function() {
           return RSVP.reject({name: trigger.name});
         });
--- a/node_modules/firebase-tools/lib/hosting/functionsProxy.js
+++ b/node_modules/firebase-tools/lib/hosting/functionsProxy.js
@@ -58,7 +58,7 @@ module.exports = function(options) {
           'Cookie': sessionCookie
         },
         followRedirect: false,
-        timeout: 60000
+        timeout: 540000
       });
 
       req.pipe(proxied);

After running firebase serve, one can verify that the first option was applied correctly:

functions describe <nameOfYourFunction>
┌────────────┬─────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Property   │ Value                                                                                                   │
├────────────┼─────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ Name       │ <nameOfYourFunction>                                                                                         │
├────────────┼─────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ Trigger    │ HTTP                                                                                                    │
├────────────┼─────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ Resource   │ http://localhost:5001/xxx/yyy                               │
├────────────┼─────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ Timeout    │ 540 seconds