firebase-tools: Functions emulator does not honor timeoutSeconds

[REQUIRED] Environment info

firebase-tools: 8.16.2

Platform: macOS 10.15.7

[REQUIRED] Test case

exports.zip = functions
  .runWith({ memory: '1GB', timeoutSeconds: 540 })
  .https
  .onRequest(zip);

[REQUIRED] Steps to reproduce

Run function on emulator such that it takes a long time to execute.

[REQUIRED] Expected behavior

I expect that the function times out in 540 seconds.

[REQUIRED] Actual behavior

The function times out in about 60 seconds (I did not time it, that is a guess).

Is it a known issue that the emulator doesn’t respect timeoutSeconds, or did I do it wrong?

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 11
  • Comments: 31 (9 by maintainers)

Commits related to this issue

Most upvoted comments

Yeah, it’s an undocumented breaking change on v10.2.0

Looks like setting env FUNCTIONS_EMULATOR_TIMEOUT_SECONDS=540s is a workaround for the dropped feature

It can be added on a .env.local file on the functions folder to be used only on emulator

Firebase CLI v11.4.0 should now support timeout on your function configuration - no need to setup FUNCTIONS_EMULATOR_TIMEOUT_SECONDS environment variable.

any updates on this one? anyone knows if there is a plan to fix this soon?

@samtstern could this be reopened? I, along with others, are still experiencing this issue.

I can confirm that @volkyeth’s workaround works.

Here’s a workaround I’ve just found while reading through the functionsEmulatorRuntime.js file:

FUNCTIONS_EMULATOR_TIMEOUT_SECONDS=120 firebase emulators:start

i having this issue as well after i upgraded to node 16

@xaphod ah ok! --inspect-functions should disable timeout behavior completely because we didn’t want people hitting timeouts while they have execution paused on a breakpoint. So maybe that’s not working?

Same issue is happening over here, I’m using firebase-tools 11.0.0.

functions
  .region('us-central1')
  .runWith({ memory: '256MB', timeoutSeconds: 120 })
  .https
  .onRequest(app)
⚠  functions: Your function timed out after ~60s. To configure this timeout, see
      https://firebase.google.com/docs/functions/manage-functions#set_timeout_and_memory_allocation.
>  /home/vagrant/.nvm/versions/node/v16.14.2/lib/node_modules/firebase-tools/lib/emulator/functionsEmulatorRuntime.js:634
>              throw new Error("Function timed out.");
>              ^
>  
>  Error: Function timed out.
>      at Timeout._onTimeout (/home/vagrant/.nvm/versions/node/v16.14.2/lib/node_modules/firebase-tools/lib/emulator/functionsEmulatorRuntime.js:634:19)
>      at listOnTimeout (node:internal/timers:559:17)
>      at processTimers (node:internal/timers:502:7)

same issue here, running firebase-tools 10.2+. Also confirm the @volkyeth workaround using the env var is working well 🙏

Also experiencing this from v1.2.0 onwards Reverting to v10.1.5 solves it

@nadermjaber had the solution that finally worked for me. package.json: “firebase-admin”: “^12.0.0”, “firebase-functions”: “^4.7.0”, “node”: “18”

globally: “firebase-tools”: 13.2.1 “node”: 20 (This is being used, I wonder if it’s the issue?)

adding the --inspect-functions flag when I started the emulator finally got it working

Yeah, it’s an undocumented breaking change on v10.2.0

Looks like setting env FUNCTIONS_EMULATOR_TIMEOUT_SECONDS=540s is a workaround for the dropped feature

It can be added on a .env.local file on the functions folder to be used only on emulator

The only way I can get the function to work locally is with the --inspect-functions flag. I wonder if its because this function uses node 20.