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.

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

See original GitHub issue

environment

Python==3.8.0 playwright==0.162.2

code

from playwright import sync_playwright

with sync_playwright() as playwright:
    browser = playwright.chromium.launch(headless=False)
    context = browser.newContext()
    page = context.newPage()
    page.goto(url)
    button_exists = page.querySelector('button[name="glowDoneButton"]')

error img

image

detail error log

(node:32864) UnhandledPromiseRejectionWarning: Error: EPIPE: broken pipe, write
    at Socket._write (internal/net.js:54:25)
    at doWrite (_stream_writable.js:403:12)
    at writeOrBuffer (_stream_writable.js:387:5)
    at Socket.Writable.write (_stream_writable.js:318:11)
    at Transport.send (C:\snapshot\playwright-cli\node_modules\playwright\lib\protocol\transport.js:38:25)
    at DispatcherConnection.onmessage (C:\snapshot\playwright-cli\lib\driver.js:49:61)
    at DispatcherConnection.sendMessageToClient (C:\snapshot\playwright-cli\node_modules\playwright\lib\dispatchers\dispatcher.js:129:14)
    at PageDispatcher._dispatchEvent (C:\snapshot\playwright-cli\node_modules\playwright\lib\dispatchers\dispatcher.js:70:26)
    at Page.<anonymous> (C:\snapshot\playwright-cli\node_modules\playwright\lib\dispatchers\pageDispatcher.js:69:63)
    at Page.emit (events.js:315:20)
(node:32864) 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(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:32864) [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.
(node:32864) UnhandledPromiseRejectionWarning: Error: EPIPE: broken pipe, write
    at Socket._write (internal/net.js:54:25)
    at doWrite (_stream_writable.js:403:12)
    at writeOrBuffer (_stream_writable.js:387:5)
    at Socket.Writable.write (_stream_writable.js:318:11)
    at Transport.send (C:\snapshot\playwright-cli\node_modules\playwright\lib\protocol\transport.js:38:25)
    at DispatcherConnection.onmessage (C:\snapshot\playwright-cli\lib\driver.js:49:61)
    at DispatcherConnection.sendMessageToClient (C:\snapshot\playwright-cli\node_modules\playwright\lib\dispatchers\dispatcher.js:129:14)
    at PageDispatcher._dispatchEvent (C:\snapshot\playwright-cli\node_modules\playwright\lib\dispatchers\dispatcher.js:70:26)
    at Page.<anonymous> (C:\snapshot\playwright-cli\node_modules\playwright\lib\dispatchers\pageDispatcher.js:65:71)
    at Page.emit (events.js:315:20)
(node:32864) 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(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:32864) UnhandledPromiseRejectionWarning: Error: EPIPE: broken pipe, write
    at Socket._write (internal/net.js:54:25)
    at doWrite (_stream_writable.js:403:12)
    at writeOrBuffer (_stream_writable.js:387:5)
    at Socket.Writable.write (_stream_writable.js:318:11)
    at Transport.send (C:\snapshot\playwright-cli\node_modules\playwright\lib\protocol\transport.js:38:25)
    at DispatcherConnection.onmessage (C:\snapshot\playwright-cli\lib\driver.js:49:61)
    at DispatcherConnection.sendMessageToClient (C:\snapshot\playwright-cli\node_modules\playwright\lib\dispatchers\dispatcher.js:129:14)
    at new Dispatcher (C:\snapshot\playwright-cli\node_modules\playwright\lib\dispatchers\dispatcher.js:61:30)
    at new RequestDispatcher (C:\snapshot\playwright-cli\node_modules\playwright\lib\dispatchers\networkDispatchers.js:32:9)
    at Function.from (C:\snapshot\playwright-cli\node_modules\playwright\lib\dispatchers\networkDispatchers.js:25:26)
(node:32864) 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(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 3)
(node:32864) UnhandledPromiseRejectionWarning: Error: EPIPE: broken pipe, write
    at Socket._write (internal/net.js:54:25)
    at doWrite (_stream_writable.js:403:12)
    at writeOrBuffer (_stream_writable.js:387:5)
    at Socket.Writable.write (_stream_writable.js:318:11)
    at Transport.send (C:\snapshot\playwright-cli\node_modules\playwright\lib\protocol\transport.js:38:25)
    at DispatcherConnection.onmessage (C:\snapshot\playwright-cli\lib\driver.js:49:61)
    at DispatcherConnection.sendMessageToClient (C:\snapshot\playwright-cli\node_modules\playwright\lib\dispatchers\dispatcher.js:129:14)
    at new Dispatcher (C:\snapshot\playwright-cli\node_modules\playwright\lib\dispatchers\dispatcher.js:61:30)
    at new ResponseDispatcher (C:\snapshot\playwright-cli\node_modules\playwright\lib\dispatchers\networkDispatchers.js:50:9)
    at Page.<anonymous> (C:\snapshot\playwright-cli\node_modules\playwright\lib\dispatchers\pageDispatcher.js:69:102)
(node:32864) 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(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 4)
(node:32864) UnhandledPromiseRejectionWarning: Error: EPIPE: broken pipe, write
    at Socket._write (internal/net.js:54:25)
    at doWrite (_stream_writable.js:403:12)
    at writeOrBuffer (_stream_writable.js:387:5)
    at Socket.Writable.write (_stream_writable.js:318:11)
    at Transport.send (C:\snapshot\playwright-cli\node_modules\playwright\lib\protocol\transport.js:38:25)
    at DispatcherConnection.onmessage (C:\snapshot\playwright-cli\lib\driver.js:49:61)
    at DispatcherConnection.sendMessageToClient (C:\snapshot\playwright-cli\node_modules\playwright\lib\dispatchers\dispatcher.js:129:14)
    at PageDispatcher._dispatchEvent (C:\snapshot\playwright-cli\node_modules\playwright\lib\dispatchers\dispatcher.js:70:26)
    at Page.<anonymous> (C:\snapshot\playwright-cli\node_modules\playwright\lib\dispatchers\pageDispatcher.js:65:71)
    at Page.emit (events.js:315:20)
(node:32864) 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(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 5)
(node:32864) UnhandledPromiseRejectionWarning: Error: EPIPE: broken pipe, write
    at Socket._write (internal/net.js:54:25)
    at doWrite (_stream_writable.js:403:12)
    at writeOrBuffer (_stream_writable.js:387:5)
    at Socket.Writable.write (_stream_writable.js:318:11)
    at Transport.send (C:\snapshot\playwright-cli\node_modules\playwright\lib\protocol\transport.js:38:25)
    at DispatcherConnection.onmessage (C:\snapshot\playwright-cli\lib\driver.js:49:61)
    at DispatcherConnection.sendMessageToClient (C:\snapshot\playwright-cli\node_modules\playwright\lib\dispatchers\dispatcher.js:129:14)
    at new Dispatcher (C:\snapshot\playwright-cli\node_modules\playwright\lib\dispatchers\dispatcher.js:61:30)
    at new RequestDispatcher (C:\snapshot\playwright-cli\node_modules\playwright\lib\dispatchers\networkDispatchers.js:32:9)
    at Function.from (C:\snapshot\playwright-cli\node_modules\playwright\lib\dispatchers\networkDispatchers.js:25:26)
(node:32864) 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(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 6)
(node:32864) UnhandledPromiseRejectionWarning: Error: EPIPE: broken pipe, write
    at Socket._write (internal/net.js:54:25)
    at doWrite (_stream_writable.js:403:12)
    at writeOrBuffer (_stream_writable.js:387:5)
    at Socket.Writable.write (_stream_writable.js:318:11)
    at Transport.send (C:\snapshot\playwright-cli\node_modules\playwright\lib\protocol\transport.js:38:25)
    at DispatcherConnection.onmessage (C:\snapshot\playwright-cli\lib\driver.js:49:61)
    at DispatcherConnection.sendMessageToClient (C:\snapshot\playwright-cli\node_modules\playwright\lib\dispatchers\dispatcher.js:129:14)
    at new Dispatcher (C:\snapshot\playwright-cli\node_modules\playwright\lib\dispatchers\dispatcher.js:61:30)
    at new ResponseDispatcher (C:\snapshot\playwright-cli\node_modules\playwright\lib\dispatchers\networkDispatchers.js:50:9)
    at Page.<anonymous> (C:\snapshot\playwright-cli\node_modules\playwright\lib\dispatchers\pageDispatcher.js:69:102)
(node:32864) 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(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 7)
(node:32864) UnhandledPromiseRejectionWarning: Error: EPIPE: broken pipe, write
    at Socket._write (internal/net.js:54:25)
    at doWrite (_stream_writable.js:403:12)
    at writeOrBuffer (_stream_writable.js:387:5)
    at Socket.Writable.write (_stream_writable.js:318:11)
    at Transport.send (C:\snapshot\playwright-cli\node_modules\playwright\lib\protocol\transport.js:38:25)
    at DispatcherConnection.onmessage (C:\snapshot\playwright-cli\lib\driver.js:49:61)
    at DispatcherConnection.sendMessageToClient (C:\snapshot\playwright-cli\node_modules\playwright\lib\dispatchers\dispatcher.js:129:14)
    at PageDispatcher._dispatchEvent (C:\snapshot\playwright-cli\node_modules\playwright\lib\dispatchers\dispatcher.js:70:26)
    at Page.<anonymous> (C:\snapshot\playwright-cli\node_modules\playwright\lib\dispatchers\pageDispatcher.js:65:71)
    at Page.emit (events.js:315:20)
(node:32864) 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(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 8)
(node:32864) UnhandledPromiseRejectionWarning: Error: EPIPE: broken pipe, write
    at Socket._write (internal/net.js:54:25)
    at doWrite (_stream_writable.js:403:12)
    at writeOrBuffer (_stream_writable.js:387:5)
    at Socket.Writable.write (_stream_writable.js:318:11)
    at Transport.send (C:\snapshot\playwright-cli\node_modules\playwright\lib\protocol\transport.js:38:25)
    at DispatcherConnection.onmessage (C:\snapshot\playwright-cli\lib\driver.js:49:61)
    at DispatcherConnection.sendMessageToClient (C:\snapshot\playwright-cli\node_modules\playwright\lib\dispatchers\dispatcher.js:129:14)
    at new Dispatcher (C:\snapshot\playwright-cli\node_modules\playwright\lib\dispatchers\dispatcher.js:61:30)
    at new RequestDispatcher (C:\snapshot\playwright-cli\node_modules\playwright\lib\dispatchers\networkDispatchers.js:32:9)
    at Function.from (C:\snapshot\playwright-cli\node_modules\playwright\lib\dispatchers\networkDispatchers.js:25:26)
(node:32864) 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(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 9)
(node:32864) UnhandledPromiseRejectionWarning: Error: EPIPE: broken pipe, write
    at Socket._write (internal/net.js:54:25)
    at doWrite (_stream_writable.js:403:12)
    at writeOrBuffer (_stream_writable.js:387:5)
    at Socket.Writable.write (_stream_writable.js:318:11)
    at Transport.send (C:\snapshot\playwright-cli\node_modules\playwright\lib\protocol\transport.js:38:25)
    at DispatcherConnection.onmessage (C:\snapshot\playwright-cli\lib\driver.js:49:61)
    at DispatcherConnection.sendMessageToClient (C:\snapshot\playwright-cli\node_modules\playwright\lib\dispatchers\dispatcher.js:129:14)
    at PageDispatcher._dispatchEvent (C:\snapshot\playwright-cli\node_modules\playwright\lib\dispatchers\dispatcher.js:70:26)
    at Page.<anonymous> (C:\snapshot\playwright-cli\node_modules\playwright\lib\dispatchers\pageDispatcher.js:42:18)
    at Page.emit (events.js:315:20)
(node:32864) 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(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 10)

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
shahrihancommented, Apr 10, 2022

Hey guys! I have also seen a similar issue while executing playwright with java: Trying to execute this script: page.waitForLoadState(); Error log: node:events:368 throw er; // Unhandled ‘error’ event ^

Error: EPIPE: broken pipe, write at Socket._write (node:internal/net:55:25) at writeOrBuffer (node:internal/streams/writable:389:12) at _write (node:internal/streams/writable:330:10) at Socket.Writable.write (node:internal/streams/writable:334:10) at Transport.send (C:\Users\NIGORA~1.MAM\AppData\Local\Temp\playwright-java-3251920591875641209\package\lib\protocol\transport.js:54:21) at DispatcherConnection.dispatcherConnection.onmessage (C:\Users\NIGORA~1.MAM\AppData\Local\Temp\playwright-java-3251920591875641209\package\lib\cli\driver.js:67:57) at DispatcherConnection.sendMessageToClient (C:\Users\NIGORA~1.MAM\AppData\Local\Temp\playwright-java-3251920591875641209\package\lib\dispatchers\dispatcher.js:187:10) at BrowserContextDispatcher._dispatchEvent (C:\Users\NIGORA~1.MAM\AppData\Local\Temp\playwright-java-3251920591875641209\package\lib\dispatchers\dispatcher.js:108:22) at CRBrowserContext.<anonymous> (C:\Users\NIGORA~1.MAM\AppData\Local\Temp\playwright-java-3251920591875641209\package\lib\dispatchers\browserContextDispatcher.js:115:16) at CRBrowserContext.emit (node:events:390:28) Emitted ‘error’ event on Socket instance at: at emitErrorNT (node:internal/streams/destroy:157:8) at emitErrorCloseNT (node:internal/streams/destroy:122:3) at processTicksAndRejections (node:internal/process/task_queues:83:21) at runNextTicks (node:internal/process/task_queues:65:3) at processImmediate (node:internal/timers:437:9) { errno: -4047, syscall: ‘write’, code: ‘EPIPE’ } The batch file cannot be found. The batch file cannot be found.

0reactions
jiangmiemiecommented, Jul 29, 2022

today I am face the same issue , I try to setDEBUG=pw:browser* , but the bug information is similar

my code is more than 1000 lines , so to get the minimum bug code is hard .

PS C:\Users\M1732\Desktop\new> node:events:368
      throw er; // Unhandled 'error' event
      ^

Error: EPIPE: broken pipe, write
    at Socket._write (node:internal/net:55:25)
    at writeOrBuffer (node:internal/streams/writable:389:12)
    at _write (node:internal/streams/writable:330:10)
    at Socket.Writable.write (node:internal/streams/writable:334:10)
    at PipeTransport.send (D:\MyProgram File\python\Lib\site-packages\playwright\driver\package\lib\protocol\transport.js:54:21)
    at DispatcherConnection.dispatcherConnection.onmessage (D:\MyProgram File\python\Lib\site-packages\playwright\driver\package\lib\cli\driver.js:67:57)
    at DispatcherConnection.sendMessageToClient (D:\MyProgram File\python\Lib\site-packages\playwright\driver\package\lib\dispatchers\dispatcher.js:187:10)
    at new Dispatcher (D:\MyProgram File\python\Lib\site-packages\playwright\driver\package\lib\dispatchers\dispatcher.js:92:40)
    at new BrowserTypeDispatcher (D:\MyProgram File\python\Lib\site-packages\playwright\driver\package\lib\dispatchers\browserTypeDispatcher.js:41:5)
    at new PlaywrightDispatcher (D:\MyProgram File\python\Lib\site-packages\playwright\driver\package\lib\dispatchers\playwrightDispatcher.js:58:17)
Emitted 'error' event on Socket instance at:
    at emitErrorNT (node:internal/streams/destroy:157:8)
    at emitErrorCloseNT (node:internal/streams/destroy:122:3)
    at processTicksAndRejections (node:internal/process/task_queues:83:21) {
  errno: -4047,
  syscall: 'write',
  code: 'EPIPE'
}
node:events:368
      throw er; // Unhandled 'error' event
      ^

Error: EOF: end of file, write
    at Socket._write (node:internal/net:55:25)
    at writeOrBuffer (node:internal/streams/writable:389:12)
    at _write (node:internal/streams/writable:330:10)
    at Socket.Writable.write (node:internal/streams/writable:334:10)
    at PipeTransport.send (D:\MyProgram File\python\Lib\site-packages\playwright\driver\package\lib\protocol\transport.js:56:21)
    at DispatcherConnection.dispatcherConnection.onmessage (D:\MyProgram File\python\Lib\site-packages\playwright\driver\package\lib\cli\driver.js:67:57)
    at DispatcherConnection.dispatch (D:\MyProgram File\python\Lib\site-packages\playwright\driver\package\lib\dispatchers\dispatcher.js:370:10)
    at runMicrotasks (<anonymous>)
    at runNextTicks (node:internal/process/task_queues:61:5)
    at processImmediate (node:internal/timers:437:9)
Emitted 'error' event on Socket instance at:
    at emitErrorNT (node:internal/streams/destroy:157:8)
    at emitErrorCloseNT (node:internal/streams/destroy:122:3)
    at processTicksAndRejections (node:internal/process/task_queues:83:21)
    at runNextTicks (node:internal/process/task_queues:65:3)
    at processImmediate (node:internal/timers:437:9) {
  errno: -4095,
  syscall: 'write',
  code: 'EOF'
}

and some information maybe helpful

  1. when I use pytest to run mycode , every thing will be ok ,so i find it too late
  2. when I just run it python -m test.test_new.test_cpu it will be have two kind A, stop and no information at the first B. give some bug information like up
Read more comments on GitHub >

github_iconTop Results From Across the Web

Execution context was destroyed, most likely because of a ...
I have a website with unpredictable behaviour when a form is submitted, it can show me a message or it redirects me to...
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 >
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 >
Puppeteer – Execution context was destroyed, most likely ...
Puppeteer – Execution context was destroyed, most likely because of a navigation – Daily IT Help.
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