Skip to content

Function rename deletion sequence change#10317

Merged
joehan merged 9 commits intofirebase:mainfrom
shettyvarun268:fix-function-rename-downtime
Apr 15, 2026
Merged

Function rename deletion sequence change#10317
joehan merged 9 commits intofirebase:mainfrom
shettyvarun268:fix-function-rename-downtime

Conversation

@shettyvarun268
Copy link
Copy Markdown
Contributor

This pull request resolves a deployment downtime issue in the Cloud Functions release process by refactoring the Fabricator class to implement a globally phased deployment strategy. Previously, function creates, updates, and deletes across all regions were executed in parallel. This behavior caused potential downtime during function renames, as an existing function could be deleted before its replacement was successfully created or updated in another region.

To address this, the execution lifecycle in applyPlan has been split into two distinct global phases separated by a wait barrier. In the first phase, all function creates and updates across all changesets are triggered and awaited simultaneously. In the second phase, deletes are executed only if all operations in the first phase completed successfully. If any create or update operation fails, all pending deletes are aborted, leaving the existing functions running in production and preventing accidental downtime.

The original applyChangeset method was preserved but refactored to accept a phase parameter. This allows it to handle either creations and updates or deletions depending on the current phase of execution directed by applyPlan. Additionally, a reusable wrapOperation helper was extracted to eliminate code duplication across operations and ensure uniform timing and error handling, making the orchestration logic easier to read and maintain.

@shettyvarun268
Copy link
Copy Markdown
Contributor Author

/gemini review

Copy link
Copy Markdown
Contributor

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

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 refactors the Fabricator to implement a two-phase deployment process, ensuring all function creations and updates across regions are completed before any deletions are initiated. Deletions are now conditionally skipped if failures occur during the first phase. Feedback focuses on strengthening the failure detection logic to account for rejected promises, refactoring the applyChangeset signature to make scraper parameters optional during the delete phase for better clarity, and improving error reporting to ensure the deployment summary remains complete even when regional operations fail to start.

Comment thread src/deploy/functions/release/fabricator.ts
Comment thread src/deploy/functions/release/fabricator.ts Outdated
Comment thread src/deploy/functions/release/fabricator.ts Outdated
Comment thread src/deploy/functions/release/fabricator.ts Outdated
Copy link
Copy Markdown
Contributor

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

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 refactors the Fabricator to implement a two-phase deployment strategy for Cloud Functions, ensuring all creations and updates across regions complete before deletions begin. Deletions are now skipped if any preceding operations fail. The applyChangeset method was updated to handle these phases, and a wrapOperation helper was added for consistent error handling and timing. Feedback was provided regarding the potential simplification of error handling in applyPlan, as certain logic appears unreachable given that wrapOperation catches all exceptions.

Comment thread src/deploy/functions/release/fabricator.ts Outdated
@shettyvarun268
Copy link
Copy Markdown
Contributor Author

/gemini review

Copy link
Copy Markdown
Contributor

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

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 refactors the Fabricator to implement a two-phase deployment strategy where all function creations and updates are executed before any deletions. If any operation in the first phase fails, the deletion phase is skipped to prevent accidental service gaps. The applyPlan and applyChangeset methods were updated to support this logic, and a new wrapOperation helper was added for consistent error handling and telemetry. Unit tests were updated to verify the sequential execution and the new return structures. I have no feedback to provide.

@shettyvarun268 shettyvarun268 requested a review from inlined April 10, 2026 20:03
@shettyvarun268 shettyvarun268 marked this pull request as ready for review April 10, 2026 20:03
Copy link
Copy Markdown
Member

@inlined inlined left a comment

Choose a reason for hiding this comment

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

TL;DR:

  1. Break a function that does two disjoint things into two functions
  2. Decide whether you handle unhandled exceptions in a function that should never throw or not. Feel free to just log it like I had so in the unlikely event we add this sort of "do something important not in the executor" we just have a debug log when the issues flood in
  3. I couldn't use reduce in the old code because reduce doesn't take async functions. If you're going to separate running code and inserting into summary.results, reduce is the functional pattern you're looking for.
  4. Try to early exit with the edge case. If you have an if {} else {} I have to keep reading past the end of the else to see if there's any code left that still applies to the if case.

Comment thread src/deploy/functions/release/fabricator.spec.ts Outdated
Comment thread src/deploy/functions/release/fabricator.ts Outdated
Comment thread src/deploy/functions/release/fabricator.ts Outdated
Comment thread src/deploy/functions/release/fabricator.ts Outdated
Comment thread src/deploy/functions/release/fabricator.ts Outdated
Comment thread src/deploy/functions/release/fabricator.ts Outdated
Comment thread src/deploy/functions/release/fabricator.ts Outdated
Comment thread src/deploy/functions/release/fabricator.ts Outdated
Comment thread src/deploy/functions/release/fabricator.ts Outdated
Comment thread src/deploy/functions/release/fabricator.ts Outdated
Comment thread src/deploy/functions/release/fabricator.ts Outdated
Comment thread src/deploy/functions/release/fabricator.ts Outdated
Comment thread src/deploy/functions/release/fabricator.ts Outdated
Comment thread src/deploy/functions/release/fabricator.ts
@joehan joehan merged commit 49f6f29 into firebase:main Apr 15, 2026
14 checks passed
joehan added a commit that referenced this pull request Apr 16, 2026
* fix(functions): fix permission denied error for Dart deployments on Windows (#10264)

* fix permission denied error for Dart deployments on Windows

* fix lint issues

* address gemini PR comments

* check the endpoint instead of pubspec

* Update src/deploy/functions/prepare.ts

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>

* Assert runtime is present

---------

Co-authored-by: Thomas Bouldin <inlined@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>

* fixing issue 6989 (#10253)

* fixing issue 6989

* adding change logs and reducing the wait time to 1s

* [mcp] ensure project root is resolved before feature detection (#10213)

Resolve the project root inside detectActiveFeatures so auto-detection does not build MCP context before cachedProjectDir is available.

Adds a regression test covering a Flutter project with firebase_crashlytics and firebase_options.dart.

Refs #10211.

Co-authored-by: Joe Hanley <joehanley@google.com>

* Rename 'functionsrunapionly' experiment 'dartfunctions'. (#10269)

Fixes #10267

Co-authored-by: Andy Perelson <ajp@google.com>

* Fix incorrect FAL event type. Add regression exception & test (#10268)

* Fix incorrect FAL event type. Add regression exception & test

* Remove redundant service lookup

* Change the default App Hosting region to us-east4 (#10271)

* Change the default App Hosting region to us-east4

* Changelog

---------

Co-authored-by: Bryan Kendall <bkend@google.com>

* middleware/proxy fixes for next.js 16 (#9631)

* middleware/proxy fixes for next.js 15/16

* changelog

* check src directory

* document middleware check in dev mode

* update middleware types docs

* Apply suggestion from @leoortizz

* remove extra space

* update changelog

* fix: detect next/image usage in client components (#10228)

* detect next/image usage in client components

* pr review

* format

* format test file

* pr review

* changelog

* feat: enable fdcrealtime by default and inject clientCache into SDK generation configurations (#10279)

* Revert "Rename 'functionsrunapionly' experiment 'dartfunctions'. (#10269)"

This reverts commit a6c0c22.

* Alternate link to Cloud Console (#10283)

* Alternate link to Cloud Console

* Fix URL. Bad AI

* Restore type safety for runtimes

* Linter error

* Update FDC emulator to v3.3.9 (#10290)

* Update FDC emulator to v3.4.1

- Upgraded Go runtime to 1.25.9.
- Bug fix: Fixed an issue that caused Angular SDK generation to fail.

* Rearrange entries in CHANGELOG.md

Reorganize changelog entries for clarity and consistency.

* Add enterprise edition support in Firestore Emulator (#10280)

* initial impl of datbase edition in fs emulator

* updated to include manual CLI override

* updated naming of flag

* quick linter fix

* update JSON schema

* fixing check on invalid flag input

* Undo nom.shrinkwrap.json change..

* Changed wrong line oops.

* removing manual flag option

* ran npm run format

* update CHANGELOG

* minor update to description

* run format

* read prod edition as well, with emulator edition taking precedence

* Update CHANGELOG.md

Co-authored-by: Joe Hanley <joehanley@google.com>

---------

Co-authored-by: Joe Hanley <joehanley@google.com>

* Another attempt to fix the npm propogation delay issues on publish (#10303)

* handle powershell stripping commas (#10288)

* handle powershell stripping commas

* remove console log

* changelog entry

* add ai suggestion

---------

Co-authored-by: Joe Hanley <joehanley@google.com>

* 15.14.0

* [firebase-release] Removed change log and reset repo after 15.14.0 release

* Increase default test timeout to 2s (#10308)

* Cache lint results for unchanged files (#9926)

* Cache lint results for unchanged files

* pr fixes

* Create new "dartfunctions" experiment

This creates a new experiment to enable Dart for Cloud Functions, and
separates out some of the dart-specific features gated by the
functionsrunapionly experiment.

* Remove unused experiments library

* Update "shows Dart as an option" test

Should be using the dartfunctions experiment now

* Updating to pubusb 0.8.30 (#10326)

* sql connect rename (#10289)

* Rename Firebase Data Connect displayed text to SQL Connect (#10270)

* Rename Data Connect displayed text to SQL Connect

Co-authored-by: fredzqm <9068391+fredzqm@users.noreply.github.com>

* Update src/emulator/dataconnectEmulator.ts

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>

* Added CHANGELOG entry

Co-authored-by: fredzqm <9068391+fredzqm@users.noreply.github.com>

* Update CHANGELOG.md

* Answered PR comments

Co-authored-by: fredzqm <9068391+fredzqm@users.noreply.github.com>

* Update experiments.ts

---------

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>

* Add a skill for addressing vulnerable dependencies in the Firebase Docker image (#10321)

* First draft of skill

* Updating docker iamge script to allow statging changes, and updating skill to use it

* Clean up script

* Update FDC emulator to v3.4.4 (#10330)

* remaining sql connect fixes (#10328)

* Reference pub.dev package in dart template (#10335)

* Clean up old broken FDL code (#10339)

* feat: remove Firebase Dynamic Links references from codebase

### Description
Removed all configurations and usages pointing to the decommissioned Firebase Dynamic Links service.

### Scenarios Tested
None applicable

### Sample Commands
None applicable

* No CHANGELOG today

* feat: add warnings when using experimental triggers in Dart runtime (#10338)

Co-authored-by: Guillaume Bernos <guillaume@bernos.dev>
Co-authored-by: Jeff <3759507+jhuleatt@users.noreply.github.com>

* fix: resolve dependency vulnerabilities and upgrade lsofi (#10342)

### Description
- Resolved multiple reported security vulnerabilities via precise overrides in package.json.
- Upgraded yaml to a safe version ^2.8.3.
- Upgraded lsofi from 1.0.0 to ^2.0.0.

### Scenarios Tested
- npm install builds cleanly.
- TypeScript compilation verified.

### Sample Commands
npm audit

* Update FDC emulator to v3.4.5 (#10343)

* Update FDC emulator to v3.4.5

- [fixed] Kotlin codegen missing comma between parameters (#10336)

* Apply suggestion from @gemini-code-assist[bot]

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>

* Update CHANGELOG.md

---------

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>

* Add a general Dart changelog entry (#10347)

* Add a general Dart changelog entry

* Update CHANGELOG.md

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>

* remove the other dart changelog line

---------

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>

* Harden FAL registration (#10306)

* Harden FAL registration

* PR feedback. Linter

---------

Co-authored-by: Joe Hanley <joehanley@google.com>

* Default function regions are decided much later in prepare (#10293)

* Default regions are decided much later in prepare and can be per-function type

* Changelog

* Update src/deploy/functions/prepare.ts

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>

* Fix stupid test bug

* typos

---------

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>

* 2.3.0 (#10357)

* Function rename deletion sequence change (#10317)

* Function rename deletion sequence change

* addressing review comments

* linting fixes

* Review changes

* Lint fixes

* Review comments

* trigger ci

* Update codcecov to v5 (#10358)

* fix: dartfunctions experiment should be able to list run services (#10354)

* fix: dartfunctions experiment should be able to list run services

Previously, trying to update a Dart function with dartfunctions enabled
would be broken because it didn't know to list the run services.

* Fix cleanup for mixed deployments

This checks for the "cloudfunctions" string in labels for v2 functions,
and temporarily adds the deployment-tool tag to the endpoint for Run
functions so it is discoverable during cleanup.

* Fix Dart Deploy.

* formatting

* test fixes

---------

Co-authored-by: Andy Perelson <ajp@google.com>
Co-authored-by: Joe Hanley <joehanley@google.com>

* Add client-name annotation to revision template for run functions (#10359)

Co-authored-by: Joe Hanley <joehanley@google.com>

* 15.15.0

* [firebase-release] Removed change log and reset repo after 15.15.0 release

* feat: add SSE mode support for MCP server

### Description
Adds support for running the MCP server in SSE (HTTP) mode, in addition to the default Stdio transport. This allows clients to connect over network or via tools that support SSE.

### Scenarios Tested
- Started server in SSE mode and verified log output.

* fix: add progressToken to McpContext interface to fix build error

### Description
Fixes a type error where progressToken was not defined on McpContext.

### Scenarios Tested
- Verified build succeeds.

* refactor: address PR comments on SSE support

### Description
Addresses PR comments by:
- Moving inline require calls to top-level imports.
- Replacing any types with specific interfaces or unknown.

### Scenarios Tested
- Verified build succeeds.

* fix: address remaining review comments on SSE support

### Description
- Reverts accidental GA4 tracking change in mcpListResources.
- Replaces console.error with this.logger calls for better logging.
- Changes default server binding from 0.0.0.0 to 127.0.0.1 for security.

### Scenarios Tested
- Verified build succeeds.

* style: lint and format fixes for SSE support

### Description
- Applied auto-formatting fixes from npm run format.

### Scenarios Tested
- Verified build succeeds.

* feat: add infrastructure for MCP Apps (#10259)

* feat: add infrastructure for MCP Apps

### Description
Adds support for returning structured content from tools, which is used by MCP Apps to pass complex data to the host. Also updates the resource index.

### Scenarios Tested
- Verified build and file changes.

* fix: resolve build errors and address review comments on infra

### Description
- Removes imports and registry entries for UI resources that are not yet available in this branch (login, update_environment, deploy, init).
- Replaces as any in toContent with an intersection type for better type safety.

### Scenarios Tested
- Verified build succeeds.

* chore: avoid any for sessionId in SSE transport

### Description
- Defines a local interface extending SSEServerTransport to avoid using  when accessing .

### Scenarios Tested
- Build succeeds.
- Lint passes for modified lines.

* feat: change sse flag to mode flag and fix build errors

### Description
- Replaced  boolean flag with  string flag (defaults to 'stdio').
- Added validation for  to accept only 'stdio' or 'sse'.
- Fixed build errors by adding  to  interface and removing missing  resource.

### Scenarios Tested
- Build succeeds.
- Lint passes with no new errors.

* feat: add mcpapps experiment flag and helper

### Description
- Adds mcpapps experiment flag to src/experiments.ts.
- Adds applyAppMeta helper function to src/mcp/util.ts to conditionally add UI metadata.
- Adds unit tests for applyAppMeta in src/mcp/util.spec.ts.

### Scenarios Tested
- Unit tests passed.
- Build succeeds.

* chore: address PR comments on experiments and util

### Description
- Fixes applyAppMeta to preserve existing metadata.
- Moves mcpapps flag to be grouped with other MCP experiments.
- Removes as any in util.spec.ts by importing CallToolResult.

### Scenarios Tested
- Build succeeds.
- Lint passes for modified files (ignoring pre-existing warnings).
- Unit tests for applyAppMeta pass.

* feat: add infrastructure for MCP Apps

Adds support for returning structured content from tools, which is used by MCP Apps to pass complex data to the host. Also updates the resource index.

- Verified build and file changes.

* feat: add Update Environment MCP App

### Description
Adds the Update Environment MCP App, allowing users to switch projects and directories from the UI.

### Scenarios Tested
- Verified build and file changes.

* feat: add Init MCP App

### Description
Adds the Init MCP App for interactive initialization of Firestore and Auth products. Includes support for Google Sign-In configuration and project selection.

### Scenarios Tested
- Verified build and file changes.

* chore: address PR comments and fix build on mcp-init-app

- Remove non-existent login_ui and deploy_ui from resources index to fix build.

- Avoid using any in mcp-app.ts, use specific interfaces.

- Check isError on tool results.

- Reduce page_size to 1000.

- Fix lint warnings for catch blocks.

* fix: add missing vite.config.ts for update_environment MCP app

* chore: add missing MCP app dependencies and update shrinkwrap on mcp-init-app

* fix: resolve lint errors for unused variables on mcp-init-app

* chore: format mcp-app.ts to fix lint issues

* refactor: clean up typing and UI options structure per review

* feat: add deploy and deploy_status tools

### Description
Adds firebase_deploy and deploy_status tools to support asynchronous deployment and status polling.

### Scenarios Tested
- Verified file changes.

* feat: use applyAppMeta in deploy tool and recover jobs.ts

### Description
- Updates deploy tool to use applyAppMeta to conditionally return UI resource URI.
- Recovers missing src/mcp/util/jobs.ts from compiled version.

### Scenarios Tested
- Build succeeds.
- Lint passes for these files.

* chore: address PR comments and fix build on mcp-deploy-tools

- Export TARGETS from src/deploy/index.ts to avoid duplication.

- Fix any usages in deploy.ts and deploy_status.ts.

- Add index signature to Job interface in jobs.ts.

- Fix lint warnings and errors.

* refactor: enforce specific types for deploy tool options

---------

Co-authored-by: Lahiru Maramba <llahiru@gmail.com>
Co-authored-by: Thomas Bouldin <inlined@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: shettyvarun268 <shettyvarun@google.com>
Co-authored-by: Luke Memet <1598289+lukemmtt@users.noreply.github.com>
Co-authored-by: Andy Perelson <ajperel@users.noreply.github.com>
Co-authored-by: Andy Perelson <ajp@google.com>
Co-authored-by: Bryan Kendall <bkend@google.com>
Co-authored-by: Leonardo Ortiz <83593673+leoortizz@users.noreply.github.com>
Co-authored-by: Akhil Raveendran <153134308+itsrakhil@users.noreply.github.com>
Co-authored-by: Wanda Mora <42626188+wandamora@users.noreply.github.com>
Co-authored-by: Fred Zhang <fredzqm@google.com>
Co-authored-by: harshyyy21 <harshoza24@gmail.com>
Co-authored-by: aalej <alejandromarco@google.com>
Co-authored-by: Google Open Source Bot <firebase-oss-bot@google.com>
Co-authored-by: Wanda Mora <morawand@google.com>
Co-authored-by: Harold Shen <hlshen@google.com>
Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
Co-authored-by: Jeff <3759507+jhuleatt@users.noreply.github.com>
Co-authored-by: Guillaume Bernos <guillaume@bernos.dev>
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.

4 participants