Skip to content

[BUG] - Multiple calls to launchPersistentContext fail in non-headless mode  #2828

@karthikiyengar

Description

@karthikiyengar

Context:

  • Playwright Version: 1.1.0-next.1593741191701
  • Operating System: Linux
  • Node version: v10.15.0
  • Browser: Chromium

Code Snippet

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

;(async () => {
  const p1 = path.join(__dirname, 'p1')
  const p2 = path.join(__dirname, 'p2')

  console.log('Launching B1')
  const b1 = await chromium.launchPersistentContext(p1, {
    headless: false,
  })
  console.log('Launching B2')
  const b2 = await chromium.launchPersistentContext(p1, {
    headless: false,
  })
  console.log('Done')
})()

Describe the bug

The code snippet fails with the error:

Launching B1
  pw:api => browserContext.waitForEvent started +0ms
  pw:api <= browserContext.waitForEvent succeeded +48ms
  pw:api => page.waitForLoadState started +0ms
  pw:api <= page.waitForLoadState succeeded +1ms
Launching B2
(node:887064) UnhandledPromiseRejectionWarning: Protocol error (Target.setDiscoverTargets): Target closed.
========= browserType.launchPersistentContext logs =========
[browser] <launching> /home/kiyengar/.cache/ms-playwright/chromium-782078/chrome-linux/chrome --disable-background-networking --enable-features=NetworkService,NetworkServiceInProcess --disable-background-timer-throttling --disable-backgrounding-occluded-windows --disable-breakpad --disable-client-side-phishing-detection --disable-component-extensions-with-background-pages --disable-default-apps --disable-dev-shm-usage --disable-extensions --disable-features=TranslateUI,BlinkGenPropertyTrees,ImprovedCookieControls,SameSiteByDefaultCookies --disable-hang-monitor --disable-ipc-flooding-protection --disable-popup-blocking --disable-prompt-on-repost --disable-renderer-backgrounding --disable-sync --force-color-profile=srgb --metrics-recording-only --no-first-run --enable-automation --password-store=basic --use-mock-keychain --user-data-dir=/home/kiyengar/development/app/clients/tests/jest-setup/p1 --remote-debugging-pipe about:blank
[browser] <launched> pid=887212
[browser] Opening in existing browser session.
============================================================
Note: use DEBUG=pw:api environment variable and rerun to capture Playwright logs.Error
    at Promise (/home/kiyengar/development/app/clients/node_modules/playwright/lib/chromium/crConnection.js:131:63)
    at new Promise (<anonymous>)
    at CRSession.send (/home/kiyengar/development/app/clients/node_modules/playwright/lib/chromium/crConnection.js:130:16)
    at CRSession.send (/home/kiyengar/development/app/clients/node_modules/playwright/lib/helper.js:79:31)
    at Function.connect (/home/kiyengar/development/app/clients/node_modules/playwright/lib/chromium/crBrowser.js:68:39)
    at Chromium._connectToTransport (/home/kiyengar/development/app/clients/node_modules/playwright/lib/server/chromium.js:51:38)
    at Chromium._innerLaunch (/home/kiyengar/development/app/clients/node_modules/playwright/lib/server/browserType.js:84:36)
(node:887064) 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: 2)
(node:887064) [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.

However, it works fine on headless mode, even with the same dataDir path. Note that this error does not occur when you provide distinct paths to launchPersistentContext in both modes.

Metadata

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