Skip to content

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

Closed

Description

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions