firebase / firebase/extensions
[bigquery-firestore-export kit] Renaming an instance creates a second scheduled query and leaves the first running
- Dominant language
- TypeScript
- Stars
- 979
- Forks
- 433
- Avg merge
- 1d 13h
- Merged PRs (30d)
- 125
Description
In the `bigquery-firestore-export` kit (`kits` branch), renaming an instance (changing its key in the `instances` map in `firebase.json`) after a first deploy creates a second BigQuery scheduled query and leaves the first one running and billable.
### Cause
Every runtime name comes from the instance id: the Pub/Sub topic the lifecycle task creates and the trigger subscribes to, the topic Data Transfer notifies, and the `extInstanceId` field stamped on the config document. The id is read once at import from the injected variable, [src/config.ts#L31](https://github.com/firebase/extensions/blob/b5c549d5a226cc31942297eb5d9b25bd744dfbcb/kits/bigquery-firestore-export/src/config.ts#L31):
```ts
const instanceId = process.env.FIREBASE_KIT_INSTANCE_ID;
```
`handleUpsertTransferConfig` finds the existing config with [`.where("extInstanceId", "==", ctx.config.instanceId)`](https://github.com/firebase/extensions/blob/b5c549d5a226cc31942297eb5d9b25bd744dfbcb/kits/bigquery-firestore-export/src/handlers.ts#L138). After a rename the query misses, so the lifecycle task creates a new scheduled query. The old one stays enabled and scheduled, notifying `kit--processMessages`, a topic whose subscriber function the CLI removes on the redeploy, with its own Firestore config document alongside. Nothing reports it. Nothing links the old config to the new id, since the kit never learns the previous key.
### Fix
Most likely documentation: the README ([Configuration](https://github.com/firebase/extensions/blob/b5c549d5a226cc31942297eb5d9b25bd744dfbcb/kits/bigquery-firestore-export/README.md#L106)) says the id is not a setting, but does not say that renaming an instance orphans its scheduled query, or that the old one must be disabled or deleted by hand. A CLI-side warning on a renamed kit instance key would catch it earlier, since the CLI knows both the old and new key and the kit does not.
Related: #2974 (ledger), #3063 (INSTANCE_ID param removed).
Contributor guide
Research direction
Start with the bigquery-firestore-export README Configuration section linked in the issue, then compare it with the instance-id behavior described in src/config.ts and src/handlers.ts. Clarify that renaming an instance can orphan an enabled scheduled query and state the required cleanup, or determine whether the CLI warning proposal is the intended fix. Done means the chosen path clearly prevents or explains this orphaned-resource case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- google-cloud, typescript
- Domain
- cloud
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 58/100