From cb56e78e9fd1ebbbaf629ee75665541b421dabbc Mon Sep 17 00:00:00 2001 From: Adam Gastineau Date: Thu, 27 Feb 2025 10:42:08 -0800 Subject: [PATCH] chore: temporarily disable floating promise warning messages --- packages/playwright/src/reporters/base.ts | 3 ++- packages/playwright/src/worker/floatingPromiseScope.ts | 3 +++ packages/playwright/src/worker/workerMain.ts | 2 ++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/playwright/src/reporters/base.ts b/packages/playwright/src/reporters/base.ts index 7affd1a016..3d905fcfca 100644 --- a/packages/playwright/src/reporters/base.ts +++ b/packages/playwright/src/reporters/base.ts @@ -270,7 +270,8 @@ export class TerminalReporter implements ReporterV2 { if (full && summary.failuresToPrint.length && !this._omitFailures) this._printFailures(summary.failuresToPrint); this._printSlowTests(); - this._printWarnings(); + // TODO: 1.52: Make warning display prettier + // this._printWarnings(); this._printSummary(summaryMessage); } diff --git a/packages/playwright/src/worker/floatingPromiseScope.ts b/packages/playwright/src/worker/floatingPromiseScope.ts index 5c3997f5e6..630183dece 100644 --- a/packages/playwright/src/worker/floatingPromiseScope.ts +++ b/packages/playwright/src/worker/floatingPromiseScope.ts @@ -23,6 +23,9 @@ export class FloatingPromiseScope { * **NOTE:** Returning from an async function wraps the result in a promise, regardless of whether the return value is a promise. This will automatically mark the promise as awaited. Avoid this. */ wrapPromiseAPIResult(promise: Promise): Promise { + if (process.env.PW_DISABLE_FLOATING_PROMISES_WARNING) + return promise; + const promiseProxy = new Proxy(promise, { get: (target, prop, receiver) => { if (prop === 'then') { diff --git a/packages/playwright/src/worker/workerMain.ts b/packages/playwright/src/worker/workerMain.ts index 91abde8a2e..1c3a006ccd 100644 --- a/packages/playwright/src/worker/workerMain.ts +++ b/packages/playwright/src/worker/workerMain.ts @@ -324,6 +324,8 @@ export class WorkerMain extends ProcessRunner { // Create warning if any of the async calls were not awaited in various stages. const checkForFloatingPromises = (functionDescription: string) => { + if (process.env.PW_DISABLE_FLOATING_PROMISES_WARNING) + return; if (!testInfo._floatingPromiseScope.hasFloatingPromises()) return; testInfo.annotations.push({ type: 'warning', description: `Some async calls were not awaited by the end of ${functionDescription}. This can cause flakiness.` });