Puppeteer request already handled: listeners and async races
A request receives a second interception resolution.
A request receives a second interception resolution.
Error message
Request is already handled!
How this error happens
An intercepted request must be resolved once. Continuing it and then aborting the same request asks Puppeteer to resolve an already-handled request.
The snippets use an open Chrome/CDP page named page.
await page.setRequestInterception(
true
);
const waiting = page.waitForRequest(
() => true
);
const navigation = page.goto(
"https://example.com/"
);
navigation.catch(() => { });
const request = await waiting;
await request.continue();
await request.abort();
How to fix
Give interception one owner. When several listeners share the page, check whether the request has already been resolved immediately before resolving it.
await page.setRequestInterception(
true
);
page.on("request", async (request) => {
if (request.isInterceptResolutionHandled()) {
return;
}
await request.continue();
});
await page.goto(
"https://example.com/"
);
Things to keep in mind
Run the corrected listener on a fresh page, without the failing listener. If a handler awaits other work, check isInterceptResolutionHandled again after that await. Handle rejected async listeners in your application’s error path.