microsoft / playwright

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
https://playwright.dev
Apache License 2.0
66.75k stars 3.66k forks source link

[Bug]: Cannot open ui or run tests with chromium - Error: browserType.launch: Target page, context or browser has been closed #29399

Closed jtibbit closed 7 months ago

jtibbit commented 9 months ago

Version

1.41.2

Steps to reproduce

similar to issue https://github.com/microsoft/playwright/issues/28500

System info Playwright Version: 1.41.2 Operating System: Mac Node.js version: v20.3.0 Browser: Chromium Reproduces: always

Source code Just installed Playwright and I'm using the test files, haven't made any changes (demo-todo-app.spec.ts and example.spec.ts)

Steps When running npx playwright test --ui, I'm getting the following: ProtocolError: Protocol error (Browser.getVersion): Internal server error, session closed.

When runningnpx playwright test, I'm getting errors on all Chromium test runs. Firefox and Webkit work fine.

Expected behavior

Can use UI mode, tests pass in chrome

Actual behavior

`Error: browserType.launch: Target page, context or browser has been closed Browser logs:

/Users/myUser/Library/Caches/ms-playwright/chromium-1097/chrome-mac/Chromium.app/Contents/MacOS/Chromium --disable-field-trial-config --disable-background-networking --enable-features=NetworkService,NetworkServiceInProcess --disable-background-timer-throttling --disable-backgrounding-occluded-windows --disable-back-forward-cache --disable-breakpad --disable-client-side-phishing-detection --disable-component-extensions-with-background-pages --disable-component-update --no-default-browser-check --disable-default-apps --disable-dev-shm-usage --disable-extensions --disable-features=ImprovedCookieControls,LazyFrameLoading,GlobalMediaControls,DestroyProfileOnBrowserClose,MediaRouter,DialMediaRouteProvider,AcceptCHFrame,AutoExpandDetailsElement,CertificateTransparencyComponentUpdater,AvoidUnnecessaryBeforeUnloadCheckSync,Translate,HttpsUpgrades,PaintHolding --allow-pre-commit-input --disable-hang-monitor --disable-ipc-flooding-protection --disable-popup-blocking --disable-prompt-on-repost --disable-renderer-backgrounding --force-color-profile=srgb --metrics-recording-only --no-first-run --enable-automation --password-store=basic --use-mock-keychain --no-service-autorun --export-tagged-pdf --disable-search-engine-choice-screen --enable-use-zoom-for-dsf=false --use-angle --headless --hide-scrollbars --mute-audio --blink-settings=primaryHoverType=2,availableHoverTypes=2,primaryPointerType=4,availablePointerTypes=4 --no-sandbox --user-data-dir=/var/folders/0_/kqkw512574d2xn91pntrmkmr0000gn/T/playwright_chromiumdev_profile-IhHsV9 --remote-debugging-pipe --no-startup-window pid=28962 Call log: - /Users/myUser/Library/Caches/ms-playwright/chromium-1097/chrome-mac/Chromium.app/Contents/MacOS/Chromium --disable-field-trial-config --disable-background-networking --enable-features=NetworkService,NetworkServiceInProcess --disable-background-timer-throttling --disable-backgrounding-occluded-windows --disable-back-forward-cache --disable-breakpad --disable-client-side-phishing-detection --disable-component-extensions-with-background-pages --disable-component-update --no-default-browser-check --disable-default-apps --disable-dev-shm-usage --disable-extensions --disable-features=ImprovedCookieControls,LazyFrameLoading,GlobalMediaControls,DestroyProfileOnBrowserClose,MediaRouter,DialMediaRouteProvider,AcceptCHFrame,AutoExpandDetailsElement,CertificateTransparencyComponentUpdater,AvoidUnnecessaryBeforeUnloadCheckSync,Translate,HttpsUpgrades,PaintHolding --allow-pre-commit-input --disable-hang-monitor --disable-ipc-flooding-protection --disable-popup-blocking --disable-prompt-on-repost --disable-renderer-backgrounding --force-color-profile=srgb --metrics-recording-only --no-first-run --enable-automation --password-store=basic --use-mock-keychain --no-service-autorun --export-tagged-pdf --disable-search-engine-choice-screen --enable-use-zoom-for-dsf=false --use-angle --headless --hide-scrollbars --mute-audio --blink-settings=primaryHoverType=2,availableHoverTypes=2,primaryPointerType=4,availablePointerTypes=4 --no-sandbox --user-data-dir=/var/folders/0_/kqkw512574d2xn91pntrmkmr0000gn/T/playwright_chromiumdev_profile-IhHsV9 --remote-debugging-pipe --no-startup-window - pid=28962` ### Additional context I've tried `npx playwright install --with-deps chromium`, `npx playwright install` and the most recent canary release to no avail. Cypress runs with Chrome work fine, so doesn't seem to be a firewall issue. I've tried using version 1.40.1, which worked fine on January 3 when I first installed Playwright, but does not seem to be working any more either. ### Environment ```shell System: OS: macOS 14.3 CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz Memory: 2.27 GB / 16.00 GB Binaries: Node: 20.3.0 - /usr/local/bin/node npm: 9.6.7 - /usr/local/bin/npm Languages: Bash: 3.2.57 - /bin/bash npmPackages: @playwright/test: ^1.41.2 => 1.41.2 playwright: ^1.41.2 => 1.41.2 ```
dgozman commented 9 months ago

@jtibbit Thank you for the issue. It seems like something's wrong on your computer, so that it cannot run Chromium. Perhaps some corporate policies?

I'd recommend running with DEBUG=pw:browser environment variable - maybe there's something useful in the logs.

DBEUG=pw:browser npx playwright test

That said, the chances that we can fix your environment are very slim.

jtibbit commented 9 months ago

Thanks for your response - I'll check to see if anything has been updated. Sorry!

abrowne2 commented 8 months ago

Still getting this, but don't have steps for repro. :|

kdevcse commented 8 months ago

Seeing this issue as well for Playwright Chromium 1097

nayanmarlin commented 7 months ago

@dgozman - it is still persist. - https://github.com/microsoft/playwright/issues/29952

kdevcse commented 7 months ago

Reverting back to playwright version 1.39.0 which uses playwright chromium 1084 fixes the issue for me. I don't know why but would be nice to get this fixed. Not sure why this issue is closed everyone at my company is experiencing this.

jtibbit commented 7 months ago

Reverting back to playwright version 1.39.0 which uses playwright chromium 1084 fixes the issue for me. I don't know why but would be nice to get this fixed. Not sure why this issue is closed everyone at my company is experiencing this.

Re-opened issue

mxschmitt commented 7 months ago

@kdevcse Would it be possible to:

  1. Set the DEBUG=pw:browser env var and try to run a Playwright test? This should give some more debug output.
  2. Try to run Chromium manually, the location of the executable is reported when the error happens, alternatively its located around here: /Users/$USER/Library/Caches/ms-playwright/chromium-/chrome-mac/Chromium.app/

This would help us a ton in order to get more debug output and debug this issue further since we have not seen many bug reports around this issue.

kdevcse commented 7 months ago

@kdevcse Would it be possible to:

  1. Set the DEBUG=pw:browser env var and try to run a Playwright test? This should give some more debug output.
  2. Try to run Chromium manually, the location of the executable is reported when the error happens, alternatively its located around here: /Users/$USER/Library/Caches/ms-playwright/chromium-/chrome-mac/Chromium.app/

This would help us a ton in order to get more debug output and debug this issue further since we have not seen many bug reports around this issue.

  1. Sure thing I've attached a debug log for a test here: debug.txt

  2. I see now this issue is listed for MacOS, but we are currently seeing this issue with Windows (it's all we use here). But here are the logs I have for that I think. Let me know if this isn't the right file: debug.log

Note: This issue/error is seen whenever any of the members on my team update our repo to use the latest version of playwright.

mxschmitt commented 7 months ago

This looks different to the original issue - do you mind uploading a self-contained minimal reproducible to GitHub where we could take a look? / run it locally? Does this happen for any new Playwright project or only in your specific repository?

kdevcse commented 7 months ago

This looks different to the original issue - do you mind uploading a self-contained minimal reproducible to GitHub where we could take a look? / run it locally? Does this happen for any new Playwright project or only in your specific repository?

I'm not sure what you mean by self-contained minimal reproducible to GitHub but sure I don't mind at all! 😆Just let me know what you need. Whatever can help us get on the latest version again.

I haven't tried a new repo but it definitely happens on our specific repository. I've tried to hunt it down but the farthest I've been able to get is it's something specific with this version of chromium +playwright and the code.

mxschmitt commented 7 months ago

yeah ideally something which we can git clone, npm install and do npx playwright test to observe the error.

kdevcse commented 7 months ago

yeah ideally something which we can git clone, npm install and do npx playwright test to observe the error.

Oh hmm well it's a private repo. Not sure how quick I would be able to spin up something small and isolated. Is there anything I can run to help debug this issue?

mxschmitt commented 7 months ago

Unfortunately not, besides the environment variable.

kdevcse commented 7 months ago

From what I can tell, it may be related to the APIRequestContext being included in a wrapper class that is instantiated in the beforeAll() and then referenced in a test. Is that a valid use case? It fails any time the APIRequestContext's post method is referenced within a test.

mxschmitt commented 7 months ago

Sounds like a duplicate of https://github.com/microsoft/playwright/issues/29260

kdevcse commented 7 months ago

Sounds like a duplicate of https://github.com/microsoft/playwright/issues/29260

Hmmm yeah I think you're right actually

mxschmitt commented 7 months ago

Folding into it

smartoryu commented 1 month ago

Seems like it's a caching issue. Just delete this directory /Users/myUser/Library/Caches/ms-playwright/ and try to run the test again. Works on my case.

john-persson-polestar commented 2 weeks ago

I'm not convinced that this is a cache issue. /Users/myUser/Library/Caches/ms-playwright seams to be where installed browsers are stored. If I delete the ms-playwright folder, then Chrome start when running playwright test --ui as expected. However, this introduces a different error in the Playwright console: Image

Following this up by running npx playwright install, adds the file which is missing in the error message from the Playwright console, but when trying to run playwright test --ui I once again get this error message:

ProtocolError: Protocol error (Browser.getVersion): Internal server error, session closed.
    at /Users/johnpersson/Sites/dotcom-web/node_modules/.pnpm/playwright-core@1.47.2/node_modules/playwright-core/lib/server/chromium/crConnection.js:135:16
    at new Promise (<anonymous>)
    at CRSession.send (/Users/johnpersson/Sites/dotcom-web/node_modules/.pnpm/playwright-core@1.47.2/node_modules/playwright-core/lib/server/chromium/crConnection.js:131:12)
    at CRBrowser.connect (/Users/johnpersson/Sites/dotcom-web/node_modules/.pnpm/playwright-core@1.47.2/node_modules/playwright-core/lib/server/chromium/crBrowser.js:51:35)
    at Chromium.connectToTransport (/Users/johnpersson/Sites/dotcom-web/node_modules/.pnpm/playwright-core@1.47.2/node_modules/playwright-core/lib/server/chromium/chromium.js:122:33)
    at Chromium._innerLaunch (/Users/johnpersson/Sites/dotcom-web/node_modules/.pnpm/playwright-core@1.47.2/node_modules/playwright-core/lib/server/browserType.js:135:32)
    at async Chromium._innerLaunchWithRetries (/Users/johnpersson/Sites/dotcom-web/node_modules/.pnpm/playwright-core@1.47.2/node_modules/playwright-core/lib/server/browserType.js:94:14)
    at async /Users/johnpersson/Sites/dotcom-web/node_modules/.pnpm/playwright-core@1.47.2/node_modules/playwright-core/lib/server/browserType.js:84:23
    at async ProgressController.run (/Users/johnpersson/Sites/dotcom-web/node_modules/.pnpm/playwright-core@1.47.2/node_modules/playwright-core/lib/server/progress.js:82:22)
    at async Chromium.launchPersistentContext (/Users/johnpersson/Sites/dotcom-web/node_modules/.pnpm/playwright-core@1.47.2/node_modules/playwright-core/lib/server/browserType.js:79:21) {
  type: 'closed',
  method: 'Browser.getVersion',
  logs: '\n' +
    '<launching> /Users/johnpersson/Library/Caches/ms-playwright/chromium-1134/chrome-mac/Chromium.app/Contents/MacOS/Chromium --disable-field-trial-config --disable-background-networking --disable-background-timer-throttling --disable-backgrounding-occluded-windows --disable-back-forward-cache --disable-breakpad --disable-client-side-phishing-detection --disable-component-extensions-with-background-pages --disable-component-update --no-default-browser-check --disable-default-apps --disable-dev-shm-usage --disable-extensions --disable-features=ImprovedCookieControls,LazyFrameLoading,GlobalMediaControls,DestroyProfileOnBrowserClose,MediaRouter,DialMediaRouteProvider,AcceptCHFrame,AutoExpandDetailsElement,CertificateTransparencyComponentUpdater,AvoidUnnecessaryBeforeUnloadCheckSync,Translate,HttpsUpgrades,PaintHolding,PlzDedicatedWorker --allow-pre-commit-input --disable-hang-monitor --disable-ipc-flooding-protection --disable-popup-blocking --disable-prompt-on-repost --disable-renderer-backgrounding --force-color-profile=srgb --metrics-recording-only --no-first-run --password-store=basic --use-mock-keychain --no-service-autorun --export-tagged-pdf --disable-search-engine-choice-screen --unsafely-disable-devtools-self-xss-warnings --enable-use-zoom-for-dsf=false --no-sandbox --app=data:text/html, --window-size=1280,800 --test-type= --user-data-dir=/var/folders/sc/mlv705m92lz9m18pfdcwv8q00000gn/T/playwright_chromiumdev_profile-a7bsGa --remote-debugging-pipe about:blank\n' +
    '<launched> pid=12824\n' +
    '[pid=12824][err] Received signal 10 BUS_ADRALN 00000bad4007\n' +
    '[pid=12824][err]  [0x000125012b00]\n' +
    '[pid=12824][err]  [0x000125006474]\n' +
    '[pid=12824][err]  [0x000125012a50]\n' +
    '[pid=12824][err]  [0x000190ef8184]\n' +
    '[pid=12824][err]  [0x00019c64bfbc]\n' +
    '[pid=12824][err]  [0x00019c6440c8]\n' +
    '[pid=12824][err]  [0x00019c643e64]\n' +
    '[pid=12824][err]  [0x00019c6414fc]\n' +
    '[pid=12824][err]  [0x00019c640dc0]\n' +
    '[pid=12824][err]  [0x00019c640cdc]\n' +
    '[pid=12824][err]  [0x00019c640b84]\n' +
    '[pid=12824][err]  [0x000194bd7438]\n' +
    '[pid=12824][err]  [0x000194bd72c8]\n' +
    '[pid=12824][err]  [0x000194ced9f8]\n' +
    '[pid=12824][err]  [0x000194ced2bc]\n' +
    '[pid=12824][err]  [0x00012598c8c8]\n' +
    '[pid=12824][err]  [0x000123dcae80]\n' +
    '[pid=12824][err]  [0x000124a9a830]\n' +
    '[pid=12824][err]  [0x000120dbe250]\n' +
    '[pid=12824][err]  [0x000123145e34]\n' +
    '[pid=12824][err]  [0x00012313d2c0]\n' +
    '[pid=12824][err]  [0x0001230da5f8]\n' +
    '[pid=12824][err]  [0x000123352ac8]\n' +
    '[pid=12824][err]  [0x00012334790c]\n' +
    '[pid=12824][err]  [0x00012a0fa150]\n' +
    '[pid=12824][err]  [0x00012a0f92f8]\n' +
    '[pid=12824][err]  [0x00012a6f9bdc]\n' +
    '[pid=12824][err]  [0x00012a6f9fb0]\n' +
    '[pid=12824][err]  [0x00012a14282c]\n' +
    '[pid=12824][err]  [0x00012a141bb8]\n' +
    '[pid=12824][err]  [0x000124a95058]\n' +
    '[pid=12824][err]  [0x000124a9485c]\n' +
    '[pid=12824][err]  [0x000122d13a7c]\n' +
    '[pid=12824][err]  [0x000123305d38]\n' +
    '[pid=12824][err]  [0x000122d13728]\n' +
    '[pid=12824][err]  [0x000122d15d4c]\n' +
    '[pid=12824][err]  [0x000122d11f88]\n' +
    '[pid=12824][err]  [0x0001244b52e4]\n' +
    '[pid=12824][err]  [0x0001244b6594]\n' +
    '[pid=12824][err]  [0x0001244b61b0]\n' +
    '[pid=12824][err]  [0x0001244b4934]\n' +
    '[pid=12824][err]  [0x0001244b4d44]\n' +
    '[pid=12824][err]  [0x000120805430]\n' +
    '[pid=12824][err]  [0x000104b68a28]\n' +
    '[pid=12824][err]  [0x000190b40274]\n' +
    '[pid=12824][err] [end of stack trace]\n' +
    '[pid=12824][err] [1016/151511.984937:WARNING:crash_report_exception_handler.cc(235)] UniversalExceptionRaise: (os/kern) failure (5)\n' +
    '[pid=12824][err] [12833:259:1016/151511.986578:ERROR:shared_memory_switch.cc(244)] Mach rendezvous failed, terminating process (parent died?)\n' +
    '[pid=12824][err] [12835:259:1016/151511.986551:ERROR:shared_memory_switch.cc(244)] Mach rendezvous failed, terminating process (parent died?)\n' +
    '[pid=12824][err] [12832:259:1016/151511.986568:ERROR:shared_memory_switch.cc(244)] Mach rendezvous failed, terminating process (parent died?)\n' +
    '[pid=12824][err] [12834:259:1016/151511.986548:ERROR:shared_memory_switch.cc(244)] Mach rendezvous failed, terminating process (parent died?)'
}
 ELIFECYCLE  Command failed with exit code 1.
fullstackzach commented 2 weeks ago

This started happening for me after I upgraded to Mac OS Sequoia 15.0.1 - deleting the cache directory as @smartoryu mentioned fixed it for me

john-persson-polestar commented 2 weeks ago

@fullstackzach , I'm on Sequoia 15.0.1 as well. I haven't been using the UI command until now, so unfortunately I've got nothing to compare with. It makes me wonder if there's anything wrong with the Chromium binary (~//Library/Caches/ms-playwright/chromium-1134/chrome-mac/Chromium.app/Contents/MacOS/Chromium) under Sequoia, but on the other hand the tests are working when running without the ui flag.

john-persson-polestar commented 2 weeks ago

Found the solution to my problem in this thread/comment: https://github.com/microsoft/playwright/issues/31064#issuecomment-2138905093