Skip to content

TimeoutErrors from AssertedEventType.Navigation can't be caught #1050

@acardnell-intruder

Description

@acardnell-intruder

I want to capture exceptions when replaying a recording and add my own custom handling, but I'm finding the following exception can't be caught:

TimeoutError: Navigation timeout of 5000 ms exceeded
2025-10-15T17:23:24.229330002Z     at new Deferred (/home/pptruser/node_modules/puppeteer-core/lib/cjs/puppeteer/util/Deferred.js:60:34)
2025-10-15T17:23:24.229330627Z     at Deferred.create (/home/pptruser/node_modules/puppeteer-core/lib/cjs/puppeteer/util/Deferred.js:21:16)
2025-10-15T17:23:24.229331336Z     at new LifecycleWatcher (/home/pptruser/node_modules/puppeteer-core/lib/cjs/puppeteer/cdp/LifecycleWatcher.js:73:60)
2025-10-15T17:23:24.229332002Z     at CdpFrame.waitForNavigation (/home/pptruser/node_modules/puppeteer-core/lib/cjs/puppeteer/cdp/Frame.js:197:29)
2025-10-15T17:23:24.229332711Z     at CdpFrame.<anonymous> (/home/pptruser/node_modules/puppeteer-core/lib/cjs/puppeteer/util/decorators.js:109:27)
2025-10-15T17:23:24.229333377Z     at waitForEvents (/home/pptruser/node_modules/@puppeteer/replay/lib/cjs/main.cjs:1643:47)
2025-10-15T17:23:24.229334044Z     at startWaitingForEvents (/home/pptruser/node_modules/@puppeteer/replay/lib/cjs/main.cjs:1464:37)
2025-10-15T17:23:24.229334711Z     at PuppeteerRunnerExtension.runStepInFrame (/home/pptruser/node_modules/@puppeteer/replay/lib/cjs/main.cjs:1573:17)
2025-10-15T17:23:24.229335502Z     at PuppeteerRunnerExtension.runStep (/home/pptruser/node_modules/@puppeteer/replay/lib/cjs/main.cjs:1456:20)
2025-10-15T17:23:24.229336169Z     at async _runStepWithHooks (/home/pptruser/node_modules/@puppeteer/replay/lib/cjs/main.cjs:1774:5)

This behaviour can be replicated fairly easily using a local Dockerised HTTPBin and the recording + script below, which attempts to navigate to the delay/10 endpoint but will trigger the default 5 second timeout:

docker pull kennethreitz/httpbin
docker run -p 8989:80 kennethreitz/httpbin
{
    "title": "httpbin delay",
    "steps": [
        {
            "type": "setViewport",
            "width": 1699,
            "height": 439,
            "deviceScaleFactor": 1,
            "isMobile": false,
            "hasTouch": false,
            "isLandscape": false
        },
        {
            "type": "navigate",
            "url": "http://localhost:8989/delay/10",
            "assertedEvents": [
                {
                    "type": "navigation",
                    "url": "http://localhost:8989/delay/10",
                    "title": ""
                }
            ]
        }
    ]
}
  const recording = <get-recording-file-json>;

  const browser = await puppeteer.launch();
  const page = await browser.newPage();

  const runner = await createRunner(recording, new PuppeteerRunnerExtension(browser, page));
  try {
    await runner.run();
  } catch (error) {
    <do-something-with-error>
  }

With the above example recording + script the expected exception will ignore the catch block as shown in the original traceback, and there doesn't seem to be any way to capture it. I've also tried creating my own custom PuppeteerRunnerExtension and wrapping the runStep method in a try / catch block, but that doesn't work either.

If you need any more information let me know.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions