Repository navigation
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request resolves an issue where retrying an initial Cloud Functions deployment could cause subsequent functions in the same region to build in parallel without a shared source token. This is achieved by swapping the order of scraper.withToken and this.functionExecutor.run in fabricator.ts, ensuring that waiting functions remain blocked on the scraper while the first function retries transient errors. Comprehensive unit tests have been added to fabricator.spec.ts to verify this behavior for both v1 and v2 functions during creation and updates. No review comments were provided, so there is no additional feedback.
ajperel
force-pushed
the
ajp/scraper-retries
branch
from
October 10, 2026 00:52
783afad to
e26c716
Compare
ajperel
requested review from
joehan and
shettyvarun268
and removed request for
joehan and
shettyvarun268
October 10, 2026 00:54
ajperel
force-pushed
the
ajp/scraper-retries
branch
2 times, most recently
from
October 17, 2026 00:17
bc3b246 to
b243205
Compare
ajperel
force-pushed
the
ajp/scraper-retries
branch
from
October 17, 2026 01:13
b243205 to
d738f17
Compare
…retries ### Description Functions deployed to the same region share one source build: the first function builds from source, and the rest wait for its source token and reuse that build. Since #11044, any retryable error on the first function (for example a quota error or a service account propagation delay) abandoned that shared build. Every waiting function then built from source in parallel, even when the retry succeeded, which slows down large deploys and uses more build quota. Waiting functions now stay on the shared build while the first function retries. Only a terminal failure of the function that is building releases them. `SourceTokenScraper.withToken` now wraps the whole retried deploy, and the token is fetched at the start of each attempt, so tokens that expire during a backoff are still refreshed. This change also: - Stops a failed build from being treated as a finished shared build. - Gives the v2 Cloud Run quota delete-and-recreate the executor's backoff and retry limit instead of an unbounded loop. - Stops v2 deploys from waiting on a shared build when `functionsv2deployoptimizations` is disabled. ### Scenarios Tested - Unit tests for `SourceTokenScraper` and `Fabricator` cover the paths that decide whether a build is shared: - The first function retrying and then succeeding, or exhausting its retries. - Failures from other functions while a build is in flight. - Token expiry during retries. - Failed operations with and without a token. - Cloud Run quota retries. - The disabled experiment. - Checked that each new test fails when the fix it covers is reverted. - `npm run test`. - Manually deployed a codebase with many functions in one region. ### Sample Commands ```bash firebase deploy --only functions ```
ajperel
force-pushed
the
ajp/scraper-retries
branch
from
October 17, 2026 01:15
d738f17 to
46ed3ea
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Functions deployed to the same region share one source build: the first function builds from source, and the rest wait for its source token and reuse that build. Since #11044, any retryable error on the first function (for example a quota error or a service account propagation delay) abandoned that shared build. Every waiting function then built from source in parallel, even when the retry succeeded, which slows down large deploys and uses more build quota.
Waiting functions now stay on the shared build while the first function retries. Only a terminal failure of the function that is building releases them.
SourceTokenScraper.withTokennow wraps the whole retried deploy, and the token is fetched at the start of each attempt, so tokens that expire during a backoff are still refreshed. This change also:functionsv2deployoptimizationsis disabled.Scenarios Tested
SourceTokenScraperandFabricatorcover the paths that decide whether a build is shared:npm run test.Sample Commands