From bd4d0febf091a9769ed03259129158817beb03f0 Mon Sep 17 00:00:00 2001 From: jrandolf <101637635+jrandolf@users.noreply.github.com> Date: Thu, 15 Feb 2024 09:16:46 +0100 Subject: [PATCH] chore: `waitForNavigation` should fail if navigation aborts or fails (#11914) --- packages/puppeteer-core/src/bidi/Frame.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/packages/puppeteer-core/src/bidi/Frame.ts b/packages/puppeteer-core/src/bidi/Frame.ts index 44bec2687ee..f1704f7c59a 100644 --- a/packages/puppeteer-core/src/bidi/Frame.ts +++ b/packages/puppeteer-core/src/bidi/Frame.ts @@ -309,7 +309,19 @@ export class BidiFrame extends Frame { fromEmitterEvent(this.browsingContext, 'navigation').pipe( switchMap(({navigation}) => { return this.#waitForLoad$(options).pipe( - raceWith(fromEmitterEvent(navigation, 'fragment')), + raceWith( + fromEmitterEvent(navigation, 'fragment'), + fromEmitterEvent(navigation, 'failed').pipe( + map(({url}) => { + throw new Error(`Navigation failed: ${url}`); + }) + ), + fromEmitterEvent(navigation, 'aborted').pipe( + map(({url}) => { + throw new Error(`Navigation aborted: ${url}`); + }) + ) + ), map(() => { return navigation; })