Skip to content

Commit d938cb9

Browse files
committed
Fix bug where v1 endpoints set concurrency opt.
1 parent 45810d2 commit d938cb9

File tree

15 files changed

+52
-36
lines changed

15 files changed

+52
-36
lines changed

src/runtime/manifest.ts

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -152,13 +152,13 @@ interface ManifestOptions {
152152
preserveExternalChanges?: boolean;
153153
}
154154

155-
/**
156-
* @internal
157-
*/
158-
export function initEndpoint(...opts: ManifestOptions[]): ManifestEndpoint {
155+
function initEndpoint(
156+
resetOptions: Record<string, unknown>,
157+
...opts: ManifestOptions[]
158+
): ManifestEndpoint {
159159
const endpoint: ManifestEndpoint = {};
160160
if (opts.every((opt) => !opt?.preserveExternalChanges)) {
161-
for (const key of Object.keys(RESETTABLE_OPTIONS)) {
161+
for (const key of Object.keys(resetOptions)) {
162162
endpoint[key] = RESET_VALUE;
163163
}
164164
// VPC settings is not flat and handled separately.
@@ -170,6 +170,22 @@ export function initEndpoint(...opts: ManifestOptions[]): ManifestEndpoint {
170170
return endpoint;
171171
}
172172

173+
/**
174+
* @internal
175+
*/
176+
export function initV1Endpoint(...opts: ManifestOptions[]): ManifestEndpoint {
177+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
178+
const { concurrency, ...resetOpts } = RESETTABLE_OPTIONS;
179+
return initEndpoint(resetOpts, ...opts);
180+
}
181+
182+
/**
183+
* @internal
184+
*/
185+
export function initV2Endpoint(...opts: ManifestOptions[]): ManifestEndpoint {
186+
return initEndpoint(RESETTABLE_OPTIONS, ...opts);
187+
}
188+
173189
const RESETTABLE_RETRY_CONFIG_OPTIONS: ResettableKeys<
174190
ManifestEndpoint["taskQueueTrigger"]["retryConfig"]
175191
> = {

src/v1/cloud-functions.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import { DeploymentOptions, RESET_VALUE } from "./function-configuration";
2626
export { Request, Response };
2727
import { convertIfPresent, copyIfPresent } from "../common/encoding";
2828
import {
29-
initEndpoint,
29+
initV1Endpoint,
3030
initV1ScheduleTrigger,
3131
ManifestEndpoint,
3232
ManifestRequiredAPI,
@@ -374,7 +374,7 @@ export function makeCloudFunction<EventData>({
374374

375375
const endpoint: ManifestEndpoint = {
376376
platform: "gcfv1",
377-
...initEndpoint(options),
377+
...initV1Endpoint(options),
378378
...optionsToEndpoint(options),
379379
};
380380

src/v1/providers/auth.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ import {
4242
optionsToEndpoint,
4343
} from "../cloud-functions";
4444
import { DeploymentOptions } from "../function-configuration";
45-
import { initEndpoint } from "../../runtime/manifest";
45+
import { initV1Endpoint } from "../../runtime/manifest";
4646

4747
// TODO: yank in next breaking change release
4848
export { UserRecord, UserInfo, UserRecordMetadata, userRecordConstructor };
@@ -216,7 +216,7 @@ export class UserBuilder {
216216
func.__endpoint = {
217217
platform: "gcfv1",
218218
labels: {},
219-
...initEndpoint(this.options),
219+
...initV1Endpoint(this.options),
220220
...optionsToEndpoint(this.options),
221221
blockingTrigger: {
222222
eventType: legacyEventType,

src/v1/providers/https.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import {
3232
} from "../../common/providers/https";
3333
import { HttpsFunction, optionsToEndpoint, Runnable } from "../cloud-functions";
3434
import { DeploymentOptions } from "../function-configuration";
35-
import { initEndpoint } from "../../runtime/manifest";
35+
import { initV1Endpoint } from "../../runtime/manifest";
3636

3737
export { Request, CallableContext, FunctionsErrorCode, HttpsError };
3838

@@ -70,7 +70,7 @@ export function _onRequestWithOptions(
7070

7171
cloudFunction.__endpoint = {
7272
platform: "gcfv1",
73-
...initEndpoint(options),
73+
...initV1Endpoint(options),
7474
...optionsToEndpoint(options),
7575
httpsTrigger: {},
7676
};
@@ -104,7 +104,7 @@ export function _onCallWithOptions(
104104
func.__endpoint = {
105105
platform: "gcfv1",
106106
labels: {},
107-
...initEndpoint(options),
107+
...initV1Endpoint(options),
108108
...optionsToEndpoint(options),
109109
callableTrigger: {},
110110
};

src/v1/providers/tasks.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import {
3131
TaskContext,
3232
} from "../../common/providers/tasks";
3333
import {
34-
initEndpoint,
34+
initV1Endpoint,
3535
initTaskQueueTrigger,
3636
ManifestEndpoint,
3737
ManifestRequiredAPI,
@@ -108,7 +108,7 @@ export class TaskQueueBuilder {
108108

109109
func.__endpoint = {
110110
platform: "gcfv1",
111-
...initEndpoint(this.depOpts),
111+
...initV1Endpoint(this.depOpts),
112112
...optionsToEndpoint(this.depOpts),
113113
taskQueueTrigger: initTaskQueueTrigger(this.depOpts),
114114
};

src/v2/providers/alerts/alerts.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2121
// SOFTWARE.
2222

23-
import { initEndpoint, ManifestEndpoint } from "../../../runtime/manifest";
23+
import { initV2Endpoint, ManifestEndpoint } from "../../../runtime/manifest";
2424
import { ResetValue } from "../../../common/options";
2525
import { CloudEvent, CloudFunction } from "../../core";
2626
import { Expression } from "../../../params";
@@ -230,7 +230,7 @@ export function getEndpointAnnotation(
230230
const baseOpts = options.optionsToEndpoint(options.getGlobalOptions());
231231
const specificOpts = options.optionsToEndpoint(opts);
232232
const endpoint: ManifestEndpoint = {
233-
...initEndpoint(options.getGlobalOptions(), opts),
233+
...initV2Endpoint(options.getGlobalOptions(), opts),
234234
platform: "gcfv2",
235235
...baseOpts,
236236
...specificOpts,

src/v2/providers/database.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import { DataSnapshot } from "../../common/providers/database";
2828
import { normalizePath } from "../../common/utilities/path";
2929
import { PathPattern } from "../../common/utilities/path-pattern";
3030
import { applyChange } from "../../common/utilities/utils";
31-
import { initEndpoint, ManifestEndpoint } from "../../runtime/manifest";
31+
import { initV2Endpoint, ManifestEndpoint } from "../../runtime/manifest";
3232
import { CloudEvent, CloudFunction } from "../core";
3333
import { Expression } from "../../params";
3434
import { wrapTraceContext } from "../trace";
@@ -428,7 +428,7 @@ export function makeEndpoint(
428428
: (eventFilters.instance = instance.getValue());
429429

430430
return {
431-
...initEndpoint(options.getGlobalOptions(), opts),
431+
...initV2Endpoint(options.getGlobalOptions(), opts),
432432
platform: "gcfv2",
433433
...baseOpts,
434434
...specificOpts,

src/v2/providers/eventarc.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
import { convertIfPresent, copyIfPresent } from "../../common/encoding";
2929
import { ResetValue } from "../../common/options";
30-
import { initEndpoint, ManifestEndpoint } from "../../runtime/manifest";
30+
import { initV2Endpoint, ManifestEndpoint } from "../../runtime/manifest";
3131
import { CloudEvent, CloudFunction } from "../core";
3232
import { wrapTraceContext } from "../trace";
3333
import { Expression } from "../../params";
@@ -199,7 +199,7 @@ export function onCustomEventPublished<T = any>(
199199
const specificOpts = options.optionsToEndpoint(opts);
200200

201201
const endpoint: ManifestEndpoint = {
202-
...initEndpoint(options.getGlobalOptions(), opts),
202+
...initV2Endpoint(options.getGlobalOptions(), opts),
203203
platform: "gcfv2",
204204
...baseOpts,
205205
...specificOpts,

src/v2/providers/https.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ import {
3838
onCallHandler,
3939
Request,
4040
} from "../../common/providers/https";
41-
import { initEndpoint, ManifestEndpoint } from "../../runtime/manifest";
42-
import * as options from "../options";
41+
import { initV2Endpoint, ManifestEndpoint } from "../../runtime/manifest";
4342
import { GlobalOptions, SupportedRegion } from "../options";
4443
import { Expression } from "../../params";
44+
import * as options from "../options";
4545

4646
export { Request, CallableRequest, FunctionsErrorCode, HttpsError };
4747

@@ -241,7 +241,7 @@ export function onRequest(
241241
// but optionsToTriggerAnnotations handles both cases.
242242
const specificOpts = options.optionsToEndpoint(opts as options.GlobalOptions);
243243
const endpoint: Partial<ManifestEndpoint> = {
244-
...initEndpoint(options.getGlobalOptions(), opts),
244+
...initV2Endpoint(options.getGlobalOptions(), opts),
245245
platform: "gcfv2",
246246
...baseOpts,
247247
...specificOpts,
@@ -305,7 +305,7 @@ export function onCall<T = any, Return = any | Promise<any>>(
305305
// but optionsToEndpoint handles both cases.
306306
const specificOpts = options.optionsToEndpoint(opts);
307307
func.__endpoint = {
308-
...initEndpoint(options.getGlobalOptions(), opts),
308+
...initV2Endpoint(options.getGlobalOptions(), opts),
309309
platform: "gcfv2",
310310
...baseOpts,
311311
...specificOpts,

src/v2/providers/identity.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ import {
3737
import { BlockingFunction } from "../../v1/cloud-functions";
3838
import { wrapTraceContext } from "../trace";
3939
import { Expression } from "../../params";
40+
import { initV2Endpoint } from "../../runtime/manifest";
4041
import * as options from "../options";
41-
import { initEndpoint } from "../../runtime/manifest";
4242

4343
export { AuthUserRecord, AuthBlockingEvent, HttpsError };
4444

@@ -284,7 +284,7 @@ export function beforeOperation(
284284
const baseOptsEndpoint = options.optionsToEndpoint(options.getGlobalOptions());
285285
const specificOptsEndpoint = options.optionsToEndpoint(opts);
286286
func.__endpoint = {
287-
...initEndpoint(options.getGlobalOptions(), opts),
287+
...initV2Endpoint(options.getGlobalOptions(), opts),
288288
platform: "gcfv2",
289289
...baseOptsEndpoint,
290290
...specificOptsEndpoint,

src/v2/providers/pubsub.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
import { copyIfPresent } from "../../common/encoding";
2929
import { ResetValue } from "../../common/options";
30-
import { initEndpoint, ManifestEndpoint } from "../../runtime/manifest";
30+
import { initV2Endpoint, ManifestEndpoint } from "../../runtime/manifest";
3131
import { CloudEvent, CloudFunction } from "../core";
3232
import { wrapTraceContext } from "../trace";
3333
import { Expression } from "../../params";
@@ -306,7 +306,7 @@ export function onMessagePublished<T = any>(
306306
const specificOpts = options.optionsToEndpoint(opts);
307307

308308
const endpoint: ManifestEndpoint = {
309-
...initEndpoint(options.getGlobalOptions(), opts),
309+
...initV2Endpoint(options.getGlobalOptions(), opts),
310310
platform: "gcfv2",
311311
...baseOpts,
312312
...specificOpts,

src/v2/providers/remoteConfig.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2121
// SOFTWARE.
2222

23-
import { initEndpoint, ManifestEndpoint } from "../../runtime/manifest";
23+
import { initV2Endpoint, ManifestEndpoint } from "../../runtime/manifest";
2424
import { CloudEvent, CloudFunction } from "../core";
2525
import { EventHandlerOptions, getGlobalOptions, optionsToEndpoint } from "../options";
2626

@@ -137,7 +137,7 @@ export function onConfigUpdated(
137137
func.run = handler;
138138

139139
const ep: ManifestEndpoint = {
140-
...initEndpoint(getGlobalOptions(), optsOrHandler),
140+
...initV2Endpoint(getGlobalOptions(), optsOrHandler),
141141
platform: "gcfv2",
142142
...baseOpts,
143143
...specificOpts,

src/v2/providers/scheduler.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import { copyIfPresent } from "../../common/encoding";
2626
import { ResetValue } from "../../common/options";
2727
import { timezone } from "../../common/timezone";
2828
import {
29-
initEndpoint,
29+
initV2Endpoint,
3030
initV2ScheduleTrigger,
3131
ManifestEndpoint,
3232
ManifestRequiredAPI,
@@ -180,7 +180,7 @@ export function onSchedule(
180180
const specificOptsEndpoint = options.optionsToEndpoint(separatedOpts.opts);
181181

182182
const ep: ManifestEndpoint = {
183-
...initEndpoint(globalOpts, separatedOpts.opts),
183+
...initV2Endpoint(globalOpts, separatedOpts.opts),
184184
platform: "gcfv2",
185185
...baseOptsEndpoint,
186186
...specificOptsEndpoint,

src/v2/providers/storage.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
import { firebaseConfig } from "../../common/config";
2929
import { copyIfPresent } from "../../common/encoding";
3030
import { ResetValue } from "../../common/options";
31-
import { initEndpoint, ManifestEndpoint } from "../../runtime/manifest";
31+
import { initV2Endpoint, ManifestEndpoint } from "../../runtime/manifest";
3232
import { CloudEvent, CloudFunction } from "../core";
3333
import { wrapTraceContext } from "../trace";
3434
import { Expression } from "../../params";
@@ -566,7 +566,7 @@ export function onOperation(
566566

567567
const endpoint: ManifestEndpoint = {
568568
platform: "gcfv2",
569-
...initEndpoint(options.getGlobalOptions(), opts),
569+
...initV2Endpoint(options.getGlobalOptions(), opts),
570570
...baseOpts,
571571
...specificOpts,
572572
labels: {

src/v2/providers/tasks.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ import * as options from "../options";
3838
import { wrapTraceContext } from "../trace";
3939
import { HttpsFunction } from "./https";
4040
import { Expression } from "../../params";
41-
import { initEndpoint, initTaskQueueTrigger } from "../../runtime/manifest";
41+
import { initV2Endpoint, initTaskQueueTrigger } from "../../runtime/manifest";
4242

4343
export { AuthData, Request };
4444

@@ -211,7 +211,7 @@ export function onTaskDispatched<Args = any>(
211211

212212
func.__endpoint = {
213213
platform: "gcfv2",
214-
...initEndpoint(options.getGlobalOptions(), opts),
214+
...initV2Endpoint(options.getGlobalOptions(), opts),
215215
...baseOpts,
216216
...specificOpts,
217217
labels: {

0 commit comments

Comments
 (0)