fix(extension): create eventChannel after initializeApp#703
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR defers creation of the EventArc channel until after the Firebase Admin app is initialized by replacing the static eventChannel export with a getEventChannel() factory and updating all usages accordingly.
- Replace
eventChannelimport withgetEventChannel()inindex.tsandwebhook-events.ts - Update
config.tsto provide agetEventChannel()function instead of a static export - Adjust unit tests and environment setup to reflect renamed functions and variables
Reviewed Changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| functions/src/index.ts | Import and invoke getEventChannel() after initializeApp() |
| functions/src/handlers/webhook-events.ts | Import and invoke getEventChannel() inside HTTP handler |
| functions/src/config.ts | Replace eventChannel constant with getEventChannel() |
| functions/tests/tests/unit/handlers/webhook-events.test.ts | Mock getEventChannel() instead of eventChannel |
| functions/tests/helpers/setupEnvironment.ts | Rename environment-path variables to consistent camelCase |
Files not reviewed (1)
- firestore-stripe-payments/functions/package-lock.json: Language not supported
Comments suppressed due to low confidence (2)
firestore-stripe-payments/functions/src/config.ts:55
- [nitpick] Add a JSDoc comment to
getEventChanneldescribing its return type (Channel | undefined) and when it returnsundefinedfor improved clarity.
export const getEventChannel = () => {
firestore-stripe-payments/functions/src/index.ts:21
- The default
configimport isn't used in this file—consider removing it to keep imports focused.
import config from './config';
| import Stripe from 'stripe'; | ||
| import * as logs from '../logs'; | ||
| import config, { eventChannel, stripe } from '../config'; | ||
| import config, { getEventChannel, stripe } from '../config'; |
There was a problem hiding this comment.
The default config import appears unused here; you can remove it to reduce unnecessary imports.
| import config, { getEventChannel, stripe } from '../config'; | |
| import { getEventChannel, stripe, stripeWebhookSecret } from '../config'; |
| }, | ||
| }, | ||
| eventChannel: null, | ||
| getEventChannel: () => null, |
There was a problem hiding this comment.
The real getEventChannel() returns undefined when EVENTARC_CHANNEL is not set; mock it to return undefined instead of null to better mirror production behavior.
| getEventChannel: () => null, | |
| getEventChannel: () => undefined, |
0b275ea to
3814699
Compare
ae317b2 to
dc0ee62
Compare
Should fix #699
TODO: