Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

browser.close hangs with beforeunload dialog #3673

Closed
aslushnikov opened this issue Dec 14, 2018 · 2 comments · Fixed by #3751
Closed

browser.close hangs with beforeunload dialog #3673

aslushnikov opened this issue Dec 14, 2018 · 2 comments · Fixed by #3751
Labels
bug chromium Issues with Puppeteer-Chromium

Comments

@aslushnikov
Copy link
Contributor

Puppeteer: v1.11.0

In headful mode, browser.close doesn't force-close browser, stalling the process in case of beforeunload dialogs. This is a little surprising to me - I'd expect beforeunloads to be ignored by default.

const puppeteer = require('puppeteer');

(async() => {
  const browser = await puppeteer.launch({
    headless: false,
    userDataDir: 'ppp',
  });
  const page = await browser.newPage();
  await page.goto('https://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_onbeforeunload');
  const frame = page.frames().find(frame => frame.name() === 'iframeResult');
  await Promise.all([
    // make sure beforeunload triggers once
    new Promise(resolve => page.once('dialog', resolve)).then(dialog => dialog.dismiss()),
    frame.click('a'),
  ]);
  // This will hang forever
  console.log('Exiting...');
  await browser.close();
  console.log('Done.');
})();
@gidztech
Copy link

I made a PR to fix this.

@aslushnikov
Copy link
Contributor Author

This was fixed upstream at https://crrev.com/618425

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug chromium Issues with Puppeteer-Chromium
Projects
None yet
2 participants