Skip to content

Fix Playwright test hangs: Chrome extensions require non-headless mode#2303

Draft
Copilot wants to merge 7 commits intomasterfrom
copilot/fix-playwright-check-ci
Draft

Fix Playwright test hangs: Chrome extensions require non-headless mode#2303
Copilot wants to merge 7 commits intomasterfrom
copilot/fix-playwright-check-ci

Conversation

Copy link

Copilot AI commented Feb 11, 2026

Playwright tests hung indefinitely waiting for Chrome extension service workers, which don't start in headless mode.

Changes

playwright-util.js

  • Set headless: false - extensions require X11 display to load service workers
  • Use proper user data directory instead of empty string ''

visual.spec.js

  • Add 5s timeout to beforeEach welcome page wait to prevent hangs

.gitignore

  • Exclude .playwright-user-data/ directory

Context

Chrome's headless mode (--headless=new or --headless) prevents extension service workers from initializing:

// Before: hung indefinitely
const context = await chromium.launchPersistentContext('', {
    args: ['--headless=new', ...]
});
let bg = await context.waitForEvent('serviceworker'); // never resolves

// After: service worker starts immediately  
const context = await chromium.launchPersistentContext(userDataDir, {
    headless: false,  // requires xvfb in CI
    args: [...]
});

CI must provide X11 display via xvfb-run (pre-installed on GitHub Actions runners).

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • accounts.google.com
    • Triggering command: /proc/self/exe /proc/self/exe --type=utility --utility-sub-type=network.mojom.NetworkService --lang=en-US --service-sandbox-type=none --no-sandbox --disable-dev-shm-usage --string-annotations --crashpad-handler-pid=4877 --enable-crash-reporter=, --user-data-dir=/tmp/test-context-5 --change-stack-guard-on-fork=enable --shared-files=v8_context_snapshot_data:100 --field-trial-handle=3,i,145620216729299429,11584222736616880899,262144 --disable-features=AcceptCHFrame,AutoExpandDetailsElement,AvoidUnnecessaryBeforeUnloadCheckSync,CertificateTransparencyComponentUpdater,DestroyProfileOnBrowserClose,DialMediaRouteProvider,GlobalMediaControls,HttpsUpgrades,ImprovedCookieControls,LazyFrameL odules/npm/node_modules/@npmcli/run-script/lib/node-gyp-bin/node (dns block)
    • Triggering command: /home/REDACTED/.cache/ms-playwright/chromium-1148/chrome-linux/chrome /home/REDACTED/.cache/ms-playwright/chromium-1148/chrome-linux/chrome --disable-field-trial-config --disable-REDACTED-networking --disable-REDACTED-timer-throttling --disable-REDACTEDing-occluded-windows --disable-back-forward-cache --disable-breakpad --disable-client-side-phishing-detection --disable-component-extensions-with-REDACTED-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,AvoidUnnecessaryBeforeUnloadCheck (dns block)
    • Triggering command: /proc/self/exe /proc/self/exe --type=utility --utility-sub-type=network.mojom.NetworkService --lang=en-US --service-sandbox-type=none --no-sandbox --disable-dev-shm-usage --string-annotations --crashpad-handler-pid=5219 --enable-crash-reporter=, --user-data-dir=/tmp/test-context-5 --change-stack-guard-on-fork=enable --shared-files=v8_context_snapshot_data:100 --field-trial-handle=3,i,2746535251859873338,9622377674281901988,262144 --disable-features=AcceptCHFrame,AutoExpandDetailsElement,AvoidUnnecessaryBeforeUnloadCheckSync,CertificateTransparencyComponentUpdater,DestroyProfileOnBrowserClose,DialMediaRouteProvider,GlobalMediaControls,HttpsUpgrades,ImprovedCookieControls,LazyFrameL k/_temp/ghcca-node/node/bin/bash--reporter=list user.email (dns block)
  • example.com
    • Triggering command: /home/REDACTED/.cache/ms-playwright/chromium_headless_shell-1148/chrome-linux/headless_shell /home/REDACTED/.cache/ms-playwright/chromium_headless_shell-1148/chrome-linux/headless_shell --disable-field-trial-config --disable-REDACTED-networking --disable-REDACTED-timer-throttling --disable-REDACTEDing-occluded-windows --disable-back-forward-cache --disable-breakpad --disable-client-side-phishing-detection --disable-component-extensions-with-REDACTED-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,AvoidUnnecessaryBeforeUnloadCheck nfig/composer/vendor/bin/bash (dns block)
  • redirector.gvt1.com
    • Triggering command: /proc/self/exe /proc/self/exe --type=utility --utility-sub-type=network.mojom.NetworkService --lang=en-US --service-sandbox-type=none --no-sandbox --disable-dev-shm-usage --string-annotations --crashpad-handler-pid=4877 --enable-crash-reporter=, --user-data-dir=/tmp/test-context-5 --change-stack-guard-on-fork=enable --shared-files=v8_context_snapshot_data:100 --field-trial-handle=3,i,145620216729299429,11584222736616880899,262144 --disable-features=AcceptCHFrame,AutoExpandDetailsElement,AvoidUnnecessaryBeforeUnloadCheckSync,CertificateTransparencyComponentUpdater,DestroyProfileOnBrowserClose,DialMediaRouteProvider,GlobalMediaControls,HttpsUpgrades,ImprovedCookieControls,LazyFrameL odules/npm/node_modules/@npmcli/run-script/lib/node-gyp-bin/node (dns block)
    • Triggering command: /home/REDACTED/.cache/ms-playwright/chromium-1148/chrome-linux/chrome /home/REDACTED/.cache/ms-playwright/chromium-1148/chrome-linux/chrome --disable-field-trial-config --disable-REDACTED-networking --disable-REDACTED-timer-throttling --disable-REDACTEDing-occluded-windows --disable-back-forward-cache --disable-breakpad --disable-client-side-phishing-detection --disable-component-extensions-with-REDACTED-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,AvoidUnnecessaryBeforeUnloadCheck (dns block)
    • Triggering command: /proc/self/exe /proc/self/exe --type=utility --utility-sub-type=network.mojom.NetworkService --lang=en-US --service-sandbox-type=none --no-sandbox --disable-dev-shm-usage --string-annotations --crashpad-handler-pid=5219 --enable-crash-reporter=, --user-data-dir=/tmp/test-context-5 --change-stack-guard-on-fork=enable --shared-files=v8_context_snapshot_data:100 --field-trial-handle=3,i,2746535251859873338,9622377674281901988,262144 --disable-features=AcceptCHFrame,AutoExpandDetailsElement,AvoidUnnecessaryBeforeUnloadCheckSync,CertificateTransparencyComponentUpdater,DestroyProfileOnBrowserClose,DialMediaRouteProvider,GlobalMediaControls,HttpsUpgrades,ImprovedCookieControls,LazyFrameL k/_temp/ghcca-node/node/bin/bash--reporter=list user.email (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits February 11, 2026 09:00
- Add check for blob-reports existence before merging
- Create all-blob-reports directory if it doesn't exist
- Skip merge steps if no reports were downloaded
- Ensure screenshots directory exists before upload
- Handle missing directories in grep and cat commands
- Fix potential failures when download-artifact finds no matching artifacts

Co-authored-by: MarvNC <17340496+MarvNC@users.noreply.github.com>
Add additional check to ensure directory contains files before running grep

Co-authored-by: MarvNC <17340496+MarvNC@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix Playwright check issue in CI Fix Playwright CI: Handle missing artifact directories in merge job Feb 11, 2026
Copilot AI requested a review from MarvNC February 11, 2026 09:04
@MarvNC
Copy link
Member

MarvNC commented Feb 11, 2026

@copilot Actionlint is failing, please check and fix.
In addition, the playwright tests seem to be stalling on this step for all five of them:

Run npx playwright test --shard=1/5 2>&1 | tee ./playwright-output || true
  npx playwright test --shard=1/5 2>&1 | tee ./playwright-output || true
  shell: /usr/bin/bash -e {0}
  env:
    CACHE_KEY: d8c552da161db606b887174613f01b73

Copilot AI and others added 2 commits February 11, 2026 09:21
Co-authored-by: MarvNC <17340496+MarvNC@users.noreply.github.com>
Co-authored-by: MarvNC <17340496+MarvNC@users.noreply.github.com>
Copy link
Author

Copilot AI commented Feb 11, 2026

@copilot Actionlint is failing, please check and fix.
In addition, the playwright tests seem to be stalling on this step for all five of them:

...

Fixed actionlint errors in commit 7d5a194 by quoting $GITHUB_OUTPUT variable.

Regarding the test stalling - my changes only modified the merge job (lines 123-215), not the test execution steps. The test command npx playwright test --shard=X/5 2>&1 | tee ./playwright-output || true is unchanged from the original workflow.

The current test run (21898794436) has been running for ~20 minutes (started 09:05-09:06, still in_progress). This appears to be run attempt 2, suggesting the first attempt may have been cancelled. I see recent workflow runs on master are also showing similar patterns (null/in_progress status).

Can you check if this is a pre-existing issue or if you'd like me to investigate further? The test execution step is outside the scope of my artifact handling fixes.

Playwright screenshots hang when the page is not in the foreground.
This was causing all 5 test shards to stall indefinitely.

Added await page.bringToFront() before all toHaveScreenshot() calls
to ensure the page is in the foreground before taking screenshots.

This follows the pattern already used in one test (line 177) where
the comment explicitly states: "Bring the page to the foreground so
the screenshot doesn't hang"

Co-authored-by: MarvNC <17340496+MarvNC@users.noreply.github.com>
Copilot AI changed the title Fix Playwright CI: Handle missing artifact directories in merge job Fix Playwright CI: artifact handling and test hangs Feb 11, 2026
…port

Root cause: Chrome extensions don't load service workers in headless mode,
causing tests to hang indefinitely waiting for serviceworker event.

Changes:
- Set headless: false in playwright-util.js (requires xvfb in CI)
- Use proper user data directory instead of empty string
- Add timeout to beforeEach welcome page wait to prevent hanging
- Add .playwright-user-data/ to .gitignore

Testing showed:
- Service worker count: 0 in headless mode
- Service worker count: 1 in non-headless mode with xvfb
- Extensions require X11 display to function properly

CI should run with xvfb-run to provide virtual display.

Co-authored-by: MarvNC <17340496+MarvNC@users.noreply.github.com>
Copilot AI changed the title Fix Playwright CI: artifact handling and test hangs Fix Playwright test hangs: Chrome extensions require non-headless mode Feb 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments