Skip to content

Commit

Permalink
Provisioning checks should be best effort (#5163)
Browse files Browse the repository at this point in the history
  • Loading branch information
joehan committed Oct 26, 2022
1 parent d67881d commit 2b4261e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
- Fixes an issue where an error during product provisioning check would block `firebase deploy --only extensions` (#5074).
- Releases RTDB Emulator v4.11.0: Wire protocol update for `startAfter`, `endBefore`.
- Changes `superstatic` dependency to `v8`, addressing Hosting emulator issues on Windows.
- Fixes internal library that was not being correctly published.
17 changes: 11 additions & 6 deletions src/extensions/provisioningHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { Client } from "../apiv2";
import { flattenArray } from "../functional";
import { FirebaseError } from "../error";
import { getExtensionSpec, InstanceSpec } from "../deploy/extensions/planner";
import { logger } from "../logger";

/** Product for which provisioning can be (or is) deferred */
export enum DeferredProduct {
Expand Down Expand Up @@ -55,12 +56,16 @@ async function checkProducts(projectId: string, usedProducts: DeferredProduct[])
if (usedProducts.includes(DeferredProduct.AUTH)) {
isAuthProvisionedPromise = isAuthProvisioned(projectId);
}

if (isStorageProvisionedPromise && !(await isStorageProvisionedPromise)) {
needProvisioning.push(DeferredProduct.STORAGE);
}
if (isAuthProvisionedPromise && !(await isAuthProvisionedPromise)) {
needProvisioning.push(DeferredProduct.AUTH);
try {
if (isStorageProvisionedPromise && !(await isStorageProvisionedPromise)) {
needProvisioning.push(DeferredProduct.STORAGE);
}
if (isAuthProvisionedPromise && !(await isAuthProvisionedPromise)) {
needProvisioning.push(DeferredProduct.AUTH);
}
} catch (err: any) {
// If a provisioning check throws, we should fail open since this is best effort.
logger.debug(`Error while checking product provisioning, failing open: ${err}`);
}

if (needProvisioning.length > 0) {
Expand Down

0 comments on commit 2b4261e

Please sign in to comment.