Skip to content

fix(registry): evaluate defaultCacheDirectory lazily#41942

Merged
dcrousso merged 1 commit into
microsoft:mainfrom
dcrousso:fix-41852
Jul 23, 2026
Merged

fix(registry): evaluate defaultCacheDirectory lazily#41942
dcrousso merged 1 commit into
microsoft:mainfrom
dcrousso:fix-41852

Conversation

@dcrousso

@dcrousso dcrousso commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

defaultCacheDirectory used to be computed inside the PLAYWRIGHT_BROWSERS_PATH branch of registryDirectory, so setting that variable skipped the platform check

#39423 hoisted it into an eagerly evaluated module constant, so it now throws Unsupported platform: <platform> at import, before registryDirectory consults PLAYWRIGHT_BROWSERS_PATH

this regressed setups that point PLAYWRIGHT_BROWSERS_PATH at their own browsers on platforms without a default cache directory, such as Android/Termux

evaluate defaultCacheDirectory, defaultRegistryDirectory, and baseDaemonDir lazily so an explicit PLAYWRIGHT_BROWSERS_PATH is honored before any default cache directory is computed

registryDirectory still throws eagerly when no override is set, since there is nowhere to place browsers

fixes #41852

@dcrousso
dcrousso requested review from pavelfeldman and yury-s July 22, 2026 21:32
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

let _defaultCacheDirectory: string | undefined;

export const defaultRegistryDirectory = path.join(defaultCacheDirectory, 'ms-playwright');
// Evaluated lazily so an explicit PLAYWRIGHT_BROWSERS_PATH lets Playwright run on

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please drop all these useless comments!

@pavelfeldman pavelfeldman left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's strip the useless comments.

`defaultCacheDirectory` used to be computed inside the `PLAYWRIGHT_BROWSERS_PATH` branch of `registryDirectory`, so setting that variable skipped the platform check

a later refactor hoisted it into an eagerly evaluated module constant, so it now throws `Unsupported platform: <platform>` at import, before `registryDirectory` consults `PLAYWRIGHT_BROWSERS_PATH`

this regressed setups that point `PLAYWRIGHT_BROWSERS_PATH` at their own browsers on platforms without a default cache directory, such as Android/Termux

evaluate `defaultCacheDirectory`, `defaultRegistryDirectory`, and `baseDaemonDir` lazily so an explicit `PLAYWRIGHT_BROWSERS_PATH` is honored before any default cache directory is computed

`registryDirectory` still throws eagerly when no override is set, since there is nowhere to place browsers
@github-actions

Copy link
Copy Markdown
Contributor

Test results for "tests 1"

5 flaky ⚠️ [chromium-library] › library/chromium/chromium.spec.ts:434 › should produce network events, routing, and annotations for Service Worker (advanced) `@realtime-time-library-chromium-linux`
⚠️ [chromium-library] › library/video.spec.ts:495 › screencast › should capture static page in persistent context @smoke `@chromium-ubuntu-22.04-node20`
⚠️ [chromium-library] › library/video.spec.ts:736 › screencast › should work with video+trace `@chromium-ubuntu-22.04-node22`
⚠️ [playwright-test] › ui-mode-trace.spec.ts:715 › should indicate current test status `@windows-latest-node22`
⚠️ [playwright-test] › ui-mode-trace.spec.ts:827 › should update state on subsequent run `@windows-latest-node22`

50308 passed, 1190 skipped


Merge workflow run.

@github-actions

Copy link
Copy Markdown
Contributor

Test results for "MCP"

1 failed
❌ [msedge] › mcp/cli-devtools.spec.ts:84 › request shows full request and response details @mcp-windows-latest-msedge

7794 passed, 1266 skipped


Merge workflow run.

@github-actions

Copy link
Copy Markdown
Contributor

Hi, I'm the Playwright bot and I took a first look at the CI failures here.

🟢 The one failure is a pre-existing flake — the PR looks clear

[msedge] › mcp/cli-devtools.spec.ts:84 › request shows full request and response details is a known low-rate flake on a test this PR doesn't touch. This PR only changes lazy evaluation of defaultCacheDirectory/registry paths, which the MCP DevTools request/response flow never exercises.

Details

Pre-existing flake / infra

  • [msedge] › mcp/cli-devtools.spec.ts:84 › request shows full request and response details — flake. The same test fails with the identical signature (expect(received).not.toBeNull()Received: null) on main at sha 4b0cc996 (firefox, push run 30002550614), where this branch can't be responsible. Across the test-results DB it otherwise passes overwhelmingly: 1 fail / 192 msedge runs, 1 / 428 firefox, 0 on 440 chrome / 435 chromium / 439 webkit.

The diff is confined to browser cache-directory resolution — registry/index.ts, serverRegistry.ts, cli-client/registry.ts, browserFactory.ts — plus a new browsers-path.spec.ts. None of that is on the code path the DevTools request-details test asserts on.

Triaged by the Playwright bot - agent run

@dcrousso
dcrousso merged commit 3e14efd into microsoft:main Jul 23, 2026
50 of 51 checks passed
@dcrousso
dcrousso deleted the fix-41852 branch July 23, 2026 18:32
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.

[Regression]: "PLAYWRIGHT_BROWSERS_PATH=0" no longer prevents evaluation of "defaultCacheDirectory" on Android/Termux

2 participants