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" happens on the page which uses meta tag refresh

See original GitHub issue

What are you trying to achieve?

I’m now testing the pages which has meta tag refresh. (You can see the detail on the code below.)

What do you get instead?

Every time I get “Error: Execution context was destroyed” when meta tag refresh happens.

Provide console output if related. Use --verbose mode for more details.

$ ./node_modules/.bin/codeceptjs run --steps --verbose
CodeceptJS v1.4.2
Using test root "/path/to/codeceptjs-sample"
Helpers: Puppeteer, Sample
Plugins: screenshotOnFail

sample --
    [1] Starting recording promises
    Emitted | suite.before ([object Object])
  sample
    Emitted | test.before ([object Object])
    Emitted | test.start ([object Object])
    Emitted | step.before (I am on page "/")
    Emitted | step.after (I am on page "/")
    Emitted | step.before (I click "a")
    Emitted | step.after (I click "a")
    Emitted | step.before (I wait for element "#toIndex2")
    Emitted | step.after (I wait for element "#toIndex2")
    Emitted | step.start (I am on page "/")
    I am on page "/"
    › [Url] http://localhost/
    › [Browser:Error] Failed to load resource: the server responded with a status of 404 (Not Found)
    Emitted | step.passed (I am on page "/")
    Emitted | step.finish (I am on page "/")
    Emitted | step.start (I click "a")
    I click "a"
    › [Url] http://localhost/index2.html
    Emitted | step.passed (I click "a")
    Emitted | step.finish (I click "a")
    Emitted | step.start (I wait for element "#toIndex2")
    I wait for element "#toIndex2"
    › [Url] http://localhost/index.html
(node:80695) UnhandledPromiseRejectionWarning: Error: Execution context was destroyed, most likely because of a navigation.
    at rewriteError (/path/to/codeceptjs-sample/node_modules/puppeteer/lib/ExecutionContext.js:144:15)
    at process._tickCallback (internal/process/next_tick.js:68:7)
(node:80695) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:80695) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
    Emitted | step.passed (I wait for element "#toIndex2")
    Emitted | step.finish (I wait for element "#toIndex2")
    Emitted | test.passed ([object Object])
    Emitted | test.finish ([object Object])
  ✔ OK in 1169ms

    Emitted | test.after ([object Object])
    Emitted | suite.after ([object Object])

  OK  | 1 passed   // 3s
    Emitted | global.result ([object Object])
    Emitted | global.after ([object Object])

$ 

Provide test source code if related

index.html
<a id="toIndex2" href="index2.html">index2</a>
index2.html
<html>
<head>
<meta http-equiv="refresh" content="0;URL='http://localhost/index.html'" />
</head>
<body>
    <a href="index.html">index</a>
</body>
</html>
test code on CodeceptJS
Feature('sample');
Scenario('sample', (I) => {
    I.amOnPage('/');
    I.click('a');
    I.waitForElement('#toIndex2');
});

Details

  • CodeceptJS version: 1.4.2
  • NodeJS Version: v10.10.0
  • Operating System: macOS High Sierra
  • Protractor || WebDriverIO || Nightmare version (if related)
  • Configuration file:
{
  "output": "./output",
  "helpers": {
    "Puppeteer": {
      "url": "http://localhost",
      "windowSize": "1280x800",
      "waitForNavigation": "networkidle0",
      "waitForTimeout": 10000,
      "chrome": {
        "args": [
          "--lang=ja,en-US,en"
        ],
        "ignoreHTTPSErrors": true
      },
      "show": true
    },
    "Sample": {
      "require": "./sample_helper.js"
    }
  },
  "include": {
    "I": "./steps_file.js"
  },
  "mocha": {},
  "bootstrap": false,
  "teardown": null,
  "hooks": [],
  "gherkin": {},
  "plugins": {
    "screenshotOnFail": {
      "enabled": true
    }
  },
  "tests": "./*_test.js",
  "timeout": 10000,
  "name": "sample"
}

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:4
  • Comments:13 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
Moshishocommented, Jan 3, 2019

Tried on CodeceptJS 2.0.1, and with waitForNavigation solution but didn’t work. Any suggestion will be appreciated.

1reaction
s-shirayamacommented, Oct 24, 2018

I’ve tried 1.4.4. But it didn’t solve this issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

"Error: Execution context was destroyed" happens on the page ...
Every time I get "Error: Execution context was destroyed" when meta tag refresh happens. Provide console output if related. Use --verbose ...
Read more >
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 >
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, most likely because of a ...
The error means that you are accessing data which has become obsolete/invalid because of navigation. In your script the error references the variable ......
Read more >
puppeteer page.evaluate() randomly fails with: Execution ...
The following code randomly fails with: Execution context was destroyed, most likely because of navigation. Why is that? Any workarounds? I use ...
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