From 56ef6d601d8f9f0d7f05fa77bf388c8516f0c837 Mon Sep 17 00:00:00 2001 From: Joe Hanley Date: Wed, 23 Sep 2026 00:06:19 +0000 Subject: [PATCH 1/3] Promote prefer-promise-reject-errors to error and fix violations --- .eslintrc.js | 2 +- src/emulator/commandUtils.ts | 12 +++++++++--- src/emulator/dataconnectEmulator.ts | 6 +++++- src/emulator/eventarcEmulator.ts | 4 +++- src/emulator/workQueue.spec.ts | 2 +- src/profileReport.ts | 10 ++++++++-- src/throttler/throttler.spec.ts | 2 +- src/utils.spec.ts | 2 ++ 8 files changed, 30 insertions(+), 10 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 29211759011..38f2b7bb59c 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -32,7 +32,7 @@ module.exports = { ], "no-prototype-builtins": "warn", // TODO(bkendall): remove, allow to error. "no-useless-escape": "warn", // TODO(bkendall): remove, allow to error. - "prefer-promise-reject-errors": "warn", // TODO(bkendall): remove, allow to error. + "prefer-promise-reject-errors": "error", }, overrides: [ { diff --git a/src/emulator/commandUtils.ts b/src/emulator/commandUtils.ts index 4306ca0fa69..06019ec27f1 100644 --- a/src/emulator/commandUtils.ts +++ b/src/emulator/commandUtils.ts @@ -336,7 +336,7 @@ function processKillSignal( res(); } catch (e: unknown) { logger.debug(e as any); - rej(); + rej(getError(e)); } }; } @@ -394,7 +394,11 @@ async function runScript(script: string, extraEnv: Record): Prom return new Promise((resolve, reject) => { proc.on("error", (err: any) => { utils.logWarning(`There was an error running the script: ${JSON.stringify(err)}`); - reject(); + reject( + new FirebaseError("There was an error running the script.", { + original: err instanceof Error ? err : undefined, + }), + ); }); // Due to the async nature of the node child_process library, sometimes @@ -406,7 +410,9 @@ async function runScript(script: string, extraEnv: Record): Prom proc.once("exit", (code, signal) => { if (signal) { utils.logWarning(`Script exited with signal: ${signal}`); - setTimeout(reject, exitDelayMs); + setTimeout(() => { + reject(new FirebaseError(`Script exited with signal: ${signal}`)); + }, exitDelayMs); return; } diff --git a/src/emulator/dataconnectEmulator.ts b/src/emulator/dataconnectEmulator.ts index a0f129604ea..be01789fd0f 100644 --- a/src/emulator/dataconnectEmulator.ts +++ b/src/emulator/dataconnectEmulator.ts @@ -175,7 +175,11 @@ export class DataConnectEmulator implements EmulatorInstance { "dataconnect", "Could not connect to SQL Connect emulator. Check dataconnect-debug.log for more details.", ); - return Promise.reject(); + return Promise.reject( + new FirebaseError( + "Could not connect to SQL Connect emulator. Check dataconnect-debug.log for more details.", + ), + ); } return Promise.resolve(); } diff --git a/src/emulator/eventarcEmulator.ts b/src/emulator/eventarcEmulator.ts index 12bbc5200a8..baf4f622c2a 100644 --- a/src/emulator/eventarcEmulator.ts +++ b/src/emulator/eventarcEmulator.ts @@ -168,7 +168,9 @@ export class EventarcEmulator implements EmulatorInstance { async triggerEventFunction(channel: string, event: CloudEvent): Promise { if (!EmulatorRegistry.isRunning(Emulators.FUNCTIONS)) { this.logger.log("INFO", "Functions emulator not found. This should not happen."); - return Promise.reject(); + return Promise.reject( + new FirebaseError("Functions emulator not found. This should not happen."), + ); } const key = `${event.type}-${channel}`; const triggers = this.events[key] || []; diff --git a/src/emulator/workQueue.spec.ts b/src/emulator/workQueue.spec.ts index df2ad4dbbb1..0e71af45075 100644 --- a/src/emulator/workQueue.spec.ts +++ b/src/emulator/workQueue.spec.ts @@ -130,7 +130,7 @@ describe("WorkQueue", () => { let hasRun1 = false; const work1 = () => { hasRun1 = true; - return Promise.reject(); + return Promise.reject(new Error("job failed")); }; let hasRun2 = false; diff --git a/src/profileReport.ts b/src/profileReport.ts index 61fa4d39486..a1594ae6ea6 100644 --- a/src/profileReport.ts +++ b/src/profileReport.ts @@ -542,8 +542,14 @@ export class ProfileReport { } } }); - rl.on("error", () => { - reject(); + rl.on("error", (err) => { + reject( + err instanceof Error + ? err + : new FirebaseError("There was an error creating the report.", { + original: err as any, + }), + ); }); outStream.on("error", () => { errored = true; diff --git a/src/throttler/throttler.spec.ts b/src/throttler/throttler.spec.ts index 5157e414223..f494a6266a1 100644 --- a/src/throttler/throttler.spec.ts +++ b/src/throttler/throttler.spec.ts @@ -168,7 +168,7 @@ const throttlerTest = (ThrottlerConstructor: ThrottlerConstructorType): void => if (count > 2) { return Promise.resolve(); } - return Promise.reject(); + return Promise.reject(new Error("retry")); }; const q = new ThrottlerConstructor({ diff --git a/src/utils.spec.ts b/src/utils.spec.ts index e8302ef82bf..9b1fdc77527 100644 --- a/src/utils.spec.ts +++ b/src/utils.spec.ts @@ -206,6 +206,7 @@ describe("utils", () => { it("should settle all promises", async () => { const result = await utils.promiseAllSettled([ Promise.resolve("foo"), + // eslint-disable-next-line prefer-promise-reject-errors Promise.reject("bar"), Promise.resolve("baz"), ]); @@ -322,6 +323,7 @@ describe("utils", () => { it("waits for all settled", async () => { // Intetionally failing with a non-error to make matching easier + // eslint-disable-next-line prefer-promise-reject-errors const reject = Promise.reject("fail fast"); const resolve = new Promise((res) => { setTimeout(() => res(42), 20); From 32e7b5975145ef0de6dffa92d844c94ab89efb26 Mon Sep 17 00:00:00 2001 From: Joe Hanley Date: Fri, 25 Sep 2026 23:34:04 +0000 Subject: [PATCH 2/3] fix: resolve CI failures on PR #11145 --- scripts/test-functions-deploy.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/test-functions-deploy.js b/scripts/test-functions-deploy.js index 9ae3e3f4249..1bd0adabb59 100644 --- a/scripts/test-functions-deploy.js +++ b/scripts/test-functions-deploy.js @@ -173,7 +173,7 @@ var waitForAck = function (uuid, testDescription) { }), new Promise(function (resolve, reject) { setTimeout(function () { - reject("Timed out while waiting for output from " + testDescription); + reject(new Error("Timed out while waiting for output from " + testDescription)); }, TIMEOUT); }), ]); From 696801bbc35ea42a15db58732bc2b3380a0a0693 Mon Sep 17 00:00:00 2001 From: Joe Hanley Date: Thu, 1 Oct 2026 22:55:47 +0000 Subject: [PATCH 3/3] fix: address PR review feedback on PR #11145 --- .eslintrc.js | 1 - 1 file changed, 1 deletion(-) diff --git a/.eslintrc.js b/.eslintrc.js index 61262127c07..5c24950081d 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -32,7 +32,6 @@ module.exports = { ], "no-prototype-builtins": "warn", // TODO(bkendall): remove, allow to error. "no-useless-escape": "warn", // TODO(bkendall): remove, allow to error. - "prefer-promise-reject-errors": "error", }, overrides: [ {