Skip to content

fix(browser): release attached emulation overrides - #3778

Merged
N0zoM1z0 merged 7 commits into
mainfrom
fix/windows-edge-service-worker-block-3752
Oct 15, 2026
Merged

N0zoM1z0 merged 7 commits into
mainfrom
fix/windows-edge-service-worker-block-3752

Conversation

@N0zoM1z0

@N0zoM1z0 N0zoM1z0 commented Oct 15, 2026 •

Copy link
Copy Markdown
Collaborator

Sequential attached-browser scenarios could fail before navigation because Chromium retained the preceding scenario's target-scoped locale override after REA disconnected. For example, the Windows Edge workflow completed its environment scenario, then the later service-worker scenario failed with Emulation.setLocaleOverride: Another locale override is already in effect.

This change gives attached environment mutations an explicit cleanup owner. It restores timezone and locale, clears device metrics, disables media emulation, and only then releases the CDP session and browser transport. Cleanup waits for an in-flight environment command before reading its ownership flags. Successful resets are retained across retries; a live target with unresolved state remains owned, while a destroyed target or disconnected browser releases an owner that cannot make further progress. An override is marked owned only after application succeeds, so REA does not clear caller-owned state when acquisition fails.

Validation:

  • npm run test:local -- src/browser/PlaywrightScenarioBrowser.test.ts (15/15, including pending-command cancellation and terminal target/transport loss)
  • npm run check:fast
  • npm run build:cached (fresh compile)
  • Real Windows Edge 154 full environment/storage/service-worker prefix passed with external-target preservation and Job0.
  • Exact review fix: real environment workflow passed CLI, stdio MCP, concurrent captures, initialization/action failures, cancellation, restoration, and external-target preservation; 59.60 s Job wall, 45.25 sampled CPU seconds, 969,183,232-byte Job peak, 1,205,497,856-byte sampled family working-set peak, Job0.
  • Exact real-browser head 151ccc960: two sequential public CLI locale/timezone scenarios passed on one external Edge target; 53.49 s Job wall, 45.42 sampled CPU seconds, 869,965,824-byte Job peak, 1,138,589,696-byte sampled family working-set peak, 12,068 parsed CLI JSON bytes, Job0.
  • Final PR head 14d9e2525 merged latest main 59f528f0e; the intervening main delta only changes JavaScript analysis files, and the browser source/test blobs are unchanged. Focused 15/15, check:fast, fresh build, all five CI shards, package/portable gates, and Chrome 155 browser / real-browser passed. Greptile reviewed this exact head at 5/5 with no blocking issue.
  • The same production verifier also passed locally under Chrome 150 in 177.20 s wall, 133.30 CPU seconds, and 557,496 KiB maximum resident set. An earlier Chrome 155 CI attempt failed once after environment/storage, then passed on the final head without code changes; it is treated as a runner/browser transient rather than fixed in this PR.
  • Three earlier independent six-round lanes passed (18/18). Full agent-token cost and an equivalent successful baseline were not measured, so no speed or token reduction is claimed.

Closes #3752

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@greptile-apps

greptile-apps Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no blocking issue remains.

Summary

Adds AttachedScenarioEnvironmentOwner to clear attached-browser environment overrides before releasing the connection.

  • Attached browser scenarios restore their overrides before releasing the browser.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Create environment owner] --> B[Apply environment settings]
  B --> C[Run scenario or report failure]
  C --> D[Wait for pending application]
  D --> E[Reset owned overrides]
  E -->|All resets succeed| F[Detach session]
  F --> G[Disconnect browser]
  E -->|Reset fails and resources remain live| H[Retain owner for retry]
  E -->|Page closed or browser disconnected| I[Release terminal owner]
Loading

Reviews (3) · Last reviewed commit: "Merge remote-tracking branch 'origin/mai..." · Reviewed by Greptile

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

Labels

area: build Build, CI, packaging, and publishing bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Windows attached browser scenarios retain locale overrides after cleanup

2 participants