Skip to content

Gen 2 Firestore-triggered function falsely diagnosed as "Changing from an HTTPS function to a background triggered function" on in-place redeploy #10680

@Lyokone

Description

@Lyokone

[REQUIRED] Environment info

firebase-tools: 15.20.0 (also reproduced on 15.21.0, the latest release at time of filing)

Platform: macOS 26.5.1 (Apple Silicon) — Node.js v22.15.0

[REQUIRED] Test case

A Gen 2 Firestore-triggered function that has always been a background trigger, deployed to a non-default region:

// functions/src/index.ts
import { onDocumentUpdated } from 'firebase-functions/v2/firestore';

export const onSceneRenderRequest = onDocumentUpdated(
  {
    document: 'orgs/{orgId}/scenes/{sceneId}',
    region: 'europe-west9',
    memory: '4GiB',
    timeoutSeconds: 300,
  },
  async (event) => {
    // ... unchanged trigger; only the body changes between deploys ...
    return null;
  }
);
  • firebase-functions: ^7.2.5
  • Functions runtime: nodejs22 (Gen 2)

The function was first deployed as a Firestore trigger and has only ever been a Firestore trigger. The deployed resource confirms it — its live eventTrigger in GCP is:

"eventTrigger": {
  "eventType": "google.cloud.firestore.document.v1.created",
  "triggerRegion": "eur3",
  "eventFilters": [
    { "attribute": "document", "value": "orgs/{orgId}/scenes/{sceneId}", "operator": "match-path-pattern" }
  ],
  "retryPolicy": "RETRY_POLICY_DO_NOT_RETRY"
}

So the deployed function is unambiguously a background trigger, yet the CLI's diff reports the existing function as HTTPS.

[REQUIRED] Steps to reproduce

  1. Deploy a Gen 2 function defined with onDocumentUpdated / onDocumentCreated (from firebase-functions/v2/firestore) to a non-default region (e.g. europe-west9).
  2. Change only the function's source code — no change to document, region, or trigger type.
  3. Redeploy in place:
    firebase deploy --only functions:onSceneRenderRequest

[REQUIRED] Expected behavior

The function is updated in place, since the trigger type is unchanged.

[REQUIRED] Actual behavior

The deploy aborts during the prepare/validation phase with:

Error: [onSceneRenderRequest(europe-west9)] Changing from an HTTPS function to a background triggered function is not allowed. Please delete your function and create a new one instead.

The function is not, and never was, an HTTPS function. No changes are applied.

Suspected cause: when building the deploy diff, the CLI classifies the already-deployed Gen 2 function as HTTPS (Gen 2 functions all run on Cloud Run and carry an HTTPS uri) instead of reading its eventTrigger to recognize it as a background trigger. It then compares "existing = https" vs "new = background trigger" and raises the trigger-type guard. Reading the deployed function's eventTrigger field (shown above, present in the GCP metadata) should let the diff identify it correctly and allow the in-place update.

Workaround (incurs downtime — Firestore events firing between delete and recreate are dropped):

firebase functions:delete onSceneRenderRequest --region europe-west9 --force
firebase deploy --only functions:onSceneRenderRequest

Impact: any project with Gen 2 background-triggered functions cannot update them in place — every code change forces a delete-and-recreate with an event-loss window. For functions in a live event path (e.g. order processing) this is a recurring production hazard.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions