Skip to content

fix(functions): make FUNCTIONS_DISCOVERY_TIMEOUT harder to misconfigure - #11628

Open
IzaakGough wants to merge 6 commits into
mainfrom
@invertase/discovery-timeout-parse
Open

IzaakGough wants to merge 6 commits into
mainfrom
@invertase/discovery-timeout-parse

Conversation

@IzaakGough

Copy link
Copy Markdown
Contributor

FUNCTIONS_DISCOVERY_TIMEOUT is read in seconds, but the timeout error printed milliseconds and did not name the variable, so values like 30000 (8.3 hours) were common.

This accepts an s or ms suffix, warns about a bare value of 600 or more and about values it cannot parse, and makes the timeout error name the variable and give the time in seconds.

  • Bare numbers still mean seconds, so existing settings keep working.
  • The parsed value is cached so the emulator does not repeat the warning once per worker.

Tested with unit tests. Not tested against a real emulator or deploy.

Accept an s or ms suffix, warn when a bare value looks like milliseconds, and
warn about values that cannot be parsed. The timeout error now names the
variable and reports the elapsed time in seconds.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request enhances the FUNCTIONS_DISCOVERY_TIMEOUT environment variable parsing to support explicit 's' and 'ms' suffixes, cache parsed values, and warn users about suspicious bare values that might be mistaken for milliseconds. It also updates the timeout error messages to be more descriptive. The review feedback recommends restricting the suspicious value warning to bare numbers to prevent incorrect remediation suggestions (such as '600sms') and calling timer.unref() on the timeout in detectFromPort to avoid keeping the Node.js event loop active unnecessarily.

@IzaakGough
IzaakGough marked this pull request as ready for review December 2, 2026 14:10

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant