Skip to content

Commit 94f6d08

Browse files
committed
chore(functions): Rename KIT_INSTANCE_ID to FIREBASE_KIT_INSTANCE_ID
1 parent d36ba25 commit 94f6d08

3 files changed

Lines changed: 26 additions & 25 deletions

File tree

src/functions/functions-api-client-internal.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ export class FunctionsApiClient {
229229
extensionOrKitId: extInstanceId,
230230
};
231231
}
232-
const kitInstanceId = process.env.KIT_INSTANCE_ID;
232+
const kitInstanceId = process.env.FIREBASE_KIT_INSTANCE_ID;
233233
if (validator.isNonEmptyString(kitInstanceId)) {
234234
return {
235235
resourceId: `kit-${kitInstanceId}-${resourceId}`,

src/functions/functions.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ export class TaskQueue<Args = Record<string, any>> {
176176
if (this.scope.scope === 'extensionOrKit') {
177177
const instance = this.scope.instance;
178178
const extInstanceId = process.env.EXT_INSTANCE_ID;
179-
const kitInstanceId = process.env.KIT_INSTANCE_ID;
179+
const kitInstanceId = process.env.FIREBASE_KIT_INSTANCE_ID;
180180
if (validator.isNonEmptyString(extInstanceId) && extInstanceId === instance) {
181181
(this.scope as any).scope = 'extension';
182182
console.warn(
@@ -280,7 +280,7 @@ export class TaskQueue<Args = Record<string, any>> {
280280
}
281281

282282
private logFallbackWarning(functionName: string, instance: string): void {
283-
const kitInstanceId = process.env.KIT_INSTANCE_ID;
283+
const kitInstanceId = process.env.FIREBASE_KIT_INSTANCE_ID;
284284
if (validator.isNonEmptyString(kitInstanceId) && kitInstanceId === instance) {
285285
// Note: It is OK to warn about kits here because targeting a kit requires the kit to be deployed first.
286286
console.warn(

test/unit/functions/functions-api-client-internal.spec.ts

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -719,7 +719,6 @@ describe('FunctionsApiClient', () => {
719719
describe('taskQueue scopes', () => {
720720
afterEach(() => {
721721
delete process.env.EXT_INSTANCE_ID;
722-
delete process.env.KIT_INSTANCE_ID;
723722
delete process.env.FIREBASE_KIT_INSTANCE_ID;
724723
});
725724

@@ -734,8 +733,8 @@ describe('FunctionsApiClient', () => {
734733
});
735734
});
736735

737-
it('should namespace function with kit- when scope is current and KIT_INSTANCE_ID is set', () => {
738-
process.env.KIT_INSTANCE_ID = 'kit-inst';
736+
it('should namespace function with kit- when scope is current and FIREBASE_KIT_INSTANCE_ID is set', () => {
737+
process.env.FIREBASE_KIT_INSTANCE_ID = 'kit-inst';
739738
const stub = sinon.stub(HttpClient.prototype, 'send').resolves(utils.responseFrom({}, 200));
740739
stubs.push(stub);
741740
return apiClient.enqueue({}, FUNCTION_NAME, { scope: 'current' })
@@ -801,29 +800,30 @@ describe('FunctionsApiClient', () => {
801800
});
802801
});
803802

804-
it('should warn with self-targeting warning and target kit directly if KIT_INSTANCE_ID matches the string',
805-
() => {
806-
process.env.KIT_INSTANCE_ID = 'my-inst';
807-
const warnStub = sinon.stub(console, 'warn');
808-
stubs.push(warnStub);
803+
it('should warn with self-targeting warning and target kit directly if ' +
804+
'FIREBASE_KIT_INSTANCE_ID matches the string',
805+
() => {
806+
process.env.FIREBASE_KIT_INSTANCE_ID = 'my-inst';
807+
const warnStub = sinon.stub(console, 'warn');
808+
stubs.push(warnStub);
809809

810-
const sendStub = sinon.stub(HttpClient.prototype, 'send').resolves(utils.responseFrom({}, 200));
811-
stubs.push(sendStub);
810+
const sendStub = sinon.stub(HttpClient.prototype, 'send').resolves(utils.responseFrom({}, 200));
811+
stubs.push(sendStub);
812812

813-
const queue = new TaskQueue(FUNCTION_NAME, apiClient, 'my-inst');
814-
return queue.enqueue({})
815-
.then(() => {
816-
expect(sendStub).to.have.been.calledOnce;
817-
expect(sendStub.firstCall.args[0].url).to.contain('/queues/kit-my-inst-function-name/tasks');
818-
expect(warnStub).to.have.been.calledOnce;
819-
expect(warnStub.firstCall.args[0]).to.equal(
820-
'Targeting your own extension or kit no longer requires a second parameter, ' +
813+
const queue = new TaskQueue(FUNCTION_NAME, apiClient, 'my-inst');
814+
return queue.enqueue({})
815+
.then(() => {
816+
expect(sendStub).to.have.been.calledOnce;
817+
expect(sendStub.firstCall.args[0].url).to.contain('/queues/kit-my-inst-function-name/tasks');
818+
expect(warnStub).to.have.been.calledOnce;
819+
expect(warnStub.firstCall.args[0]).to.equal(
820+
'Targeting your own extension or kit no longer requires a second parameter, ' +
821821
'which can have performance implications. Please change the call ' +
822822
`taskQueue('${FUNCTION_NAME}', 'my-inst') to taskQueue('${FUNCTION_NAME}') ` +
823823
`or taskQueue('${FUNCTION_NAME}', { scope: "current" })`
824-
);
825-
});
826-
});
824+
);
825+
});
826+
});
827827

828828
it('should warn with self-targeting warning and target extension directly if EXT_INSTANCE_ID matches the string',
829829
() => {
@@ -847,7 +847,8 @@ describe('FunctionsApiClient', () => {
847847
});
848848
});
849849

850-
it('should warn with kit legacy warning if kit fallback succeeds and KIT_INSTANCE_ID does not match', () => {
850+
it('should warn with kit legacy warning if kit fallback succeeds and ' +
851+
'FIREBASE_KIT_INSTANCE_ID does not match', () => {
851852
const warnStub = sinon.stub(console, 'warn');
852853
stubs.push(warnStub);
853854

0 commit comments

Comments
 (0)