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.

[BUG] 0.15 Cannot launch new chromium context after closing old one

See original GitHub issue

Context:

  • Playwright Version: 0.15.0
  • Operating System: macOS 10.15.4

Code Snippet

let browser;

beforeAll(async () => {
  browser = await playwright['chromium'].launch({
    headless: false,
  });
});

afterAll(async () => {
  await browser.close();
});

test('1', async () => {
  const context = await browser.newContext();
  const page = await context.newPage();

  await page.goto('http://www.example.com');
  await context.close();
});

test('2', async () => {
  const context = await browser.newContext();
  const page = await context.newPage();

  await page.goto('http://www.example.com');
  await context.close();
});

Describe the bug

Error output:

    Protocol error (Target.createBrowserContext): Target closed.

      32 |     await context.close();
      33 |
    > 34 |     const context2 = await browser.newContext();
         |                                    ^
      35 |
      36 |     const page2 = await context2.newPage();
      37 |

      at Promise (node_modules/playwright-core/lib/chromium/crConnection.js:130:63)
      at CRSession.send (node_modules/playwright-core/lib/chromium/crConnection.js:129:16)
      at CRSession.<anonymous> (node_modules/playwright-core/lib/helper.js:64:31)
      at CRBrowser.newContext (node_modules/playwright-core/lib/chromium/crBrowser.js:93:58)
      at CRBrowser.newContext (node_modules/playwright-core/lib/helper.js:64:31)
      at _callee3$ (tests/playwright/login.test.js:34:36)
      at tryCatch (node_modules/regenerator-runtime/runtime.js:45:40)
      at Generator.invoke [as _invoke] (node_modules/regenerator-runtime/runtime.js:274:22)
      at Generator.prototype.(anonymous function) [as next] (node_modules/regenerator-runtime/runtime.js:97:21)
      at asyncGeneratorStep (tests/playwright/login.test.js:11:103)
      at _next (tests/playwright/login.test.js:13:194)

This does seems to work for webkit and firefox.

Not sure if I’m doing something wrong – I did see this note in the docs: the default browser context cannot be closed. but it wasn’t clear to me if this meant “you cannot close the first new context you create via invoking newContext()” or “you cannot close a context if you do not invoke newContext() at all”.

Thanks!

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
yury-scommented, Apr 28, 2020
0reactions
yury-scommented, Apr 27, 2020

Minimal repro case:

const { chromium } = require('playwright');

(async () => {
  const browser = await chromium.launch({
    headless: false,
  });
  const context = await browser.newContext();
  await context.newPage();
  await context.close();
})();
Read more comments on GitHub >

github_iconTop Results From Across the Web

Chrome returns black screen with no logged errors on WebGL ...
1. Open those URLs 2. In the last URL example, the blending appears to be broken. ... this bug or have new data,...
Read more >
Changelog - Cypress Documentation
Fixed a regression in 8.3.0 where Cypress would cause a SIGSEGV error on Mac when closing the Cypress app opened via cypress open...
Read more >
Bug listing with status UNCONFIRMED as at 2022/12/24 17 ...
system fails to shutdown with automount+nfs" status:UNCONFIRMED resolution: severity: ... Bug:547510 - "net-misc/netifrc: udhcpc can not run in background" ...
Read more >
Playwright v0.16.0 release notes (2020-05-01) | LibHunt
Playwright now uses a single location on your machine to install all ... #1962 - [BUG] 0.15 Cannot launch new chromium context after...
Read more >
JupyterLab Changelog — JupyterLab 3.6.0b0 documentation
Bump to the latest Lumino 1.x #13190 (@fcollonval) ... Fix debugger extension error when notebooks is closed quickly #12396 (@fcollonval).
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