question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error: Execution context was destroyed, most likely because of a navigation.

See original GitHub issue

Tell us about your environment:

  • Puppeteer version: 1.13.0
  • Platform / OS version: OSX 10.14
  • Node.js version: v9.10.0
const puppeteer = require('puppeteer');

const jsonReturn = [];

(async () => {
  const browser = await puppeteer.launch({
    headless: false,
    devtools: true
  });

  const page = await browser.newPage();
  await page.evaluate(() => {
    debugger;
  });
  const response = await page.goto('https://myurl.com');

  console.log('served from cache?', response.fromCache());

  // debugger;
  await page.waitForSelector('.featured-shows-featured-show');

  const featuredShows = await page.$$('.featured-shows-featured-show');

  for (const featuredShow of featuredShows) {
    debugger;
    const link = await featuredShow.$('a');
    link.click();

    await page.waitForSelector('.show-title');

    debugger;

    const showTitle = page.$('.show-title')
    const showDates = page.$('.show-dates')
    const showLocation = page.$('.show-location')
    const showGallery = page.$('.entity-link')
    const showDetail = page.$('.show-press-release')

    jsonReturn.push({
      showTitle,
      showDates,
      showLocation,
      showGallery,
      showDetail,
    });


    await page.goBack();
  }

  console.log(jsonReturn);


  await browser.close();
})();

Getting Error: UnhandledPromiseRejectionWarning: Error: Execution context was destroyed, most likely because of a navigation.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
Partomcommented, Apr 18, 2019

I am also facing same issue and working on same scenario. @stoplion Can you please share that how do you fixed this issue ?

Thanks in Advance 👍

0reactions
jameskipcommented, Oct 17, 2019

I’m having a similar issue. I would like to cycle through a list then goBack click another link and cycle through that list as well. However, it is losing the handle when I navigate back.

for (let i = 0; i < categories.length; i++) {
    it(`should display categories: ${categories[i]}`, async (done) => {
      await page.goto(`${environment.production}/categories/${categories[i]}`)
      const cards = await page.$$('a')

      for (const card of cards) {
        await card.click()
        await page.waitForNavigation()
        await page.goBack()
        await page.waitForNavigation()
      }

      done()
    })
  }
Read more comments on GitHub >

github_iconTop Results From Across the Web

Puppeteer Execution context was destroyed, most likely ...
The error means that you are accessing data which has become obsolete/invalid because of navigation. In your script the error references the ...
Read more >
Execution context was destroyed, most likely ... - GitHub
I am getting the same error using Puppeteer "version": "1.13.0". ERROR: Execution context was destroyed, most likely because of a navigation.
Read more >
Puppeteer: "Execution context was destroyed, most likely ...
To fix the “execution context was destroyed, most likely because of a navigation” error, use the page.waitForNavigation() function: const ...
Read more >
Execution context was destroyed, because of navigation
We are having a issue in Ultimate PDF when trying to generate a single PDF. Last week, It's working but unfortunately it doesn't...
Read more >
playwright._impl._api_types.error: execution context was ...
To fix the “execution context was destroyed, most likely because of a navigation” error, use the page.waitForNavigation () function: The page.waitForNavigation ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found