Puppeteer: Cannot cancel prompt through detached session!
The device prompt's CDP session was detached.
The device prompt’s CDP session was detached.
Error message
Cannot cancel prompt through detached session!
How this error happens
A device chooser depends on a live page session. Closing the page before canceling the prompt removes that session.
Assume page is open, prompt is its current device chooser and device belongs to that prompt. Run the failing and corrected sequences separately.
await page.close();
await prompt.cancel();
How to fix
Complete or cancel the chooser while the page is alive, then close the page.
await prompt.cancel();
await page.close();
Things to keep in mind
The exact error depends on whether the page closure is observed before or during the operation. Reopening a page does not revive an old prompt; wait for a new prompt on the new page.