Skip to content

Restore fresh Worker RPC after top-level realm replacement #872

Description

@wieslawsoltes

Problem

The exact packaged Code OSS 1.137 acceptance run on AppScene 52c3f302 / WebScene 46011413 passes the first Monaco editor Worker $computeUnicodeHighlights request/reply, the browser extension-host iframe/MessagePort handshake, and MCP secret storage. After the smoke performs a same-origin location.reload() to verify the stored MCP secret, the replacement workbench constructs a new editorWorkerService Worker but never calls its postMessage with the Unicode-highlighter RPC before the 15-second bound expires.

Evidence from artifacts/smoke-52c3f30-4601141-final/native-smoke.json:

  • native navigation count: 2;
  • second realm: editorWorkerConstructed=true;
  • second realm: editorWorkerRequest and editorWorkerReply absent;
  • extension iframe, transferred MessagePort, Ready, and Initialized all reached;
  • UI timer advanced 1,824 ticks;
  • server key mint endpoint was called twice, proving the run crossed the MCP storage/reload boundary;
  • the extension host briefly reported unresponsive and then responsive;
  • failure: The unchanged Unicode highlighter did not complete an editor Worker RPC.

The current direct navigation test retires a pre-navigation Worker but only constructs a MessageChannel after navigation. It does not prove that a fresh Worker created by the replacement realm can start, accept a request, publish its reply, and wake the host.

Parent: #81. This is a focused replacement-realm Worker lifecycle slice.

Investigation and implementation

  1. Extend the native Worker navigation contract to create an RPC Worker before navigation, replace the top-level realm, then create a second RPC Worker and verify an ordered request/reply from the replacement realm.
  2. Record bounded startup, parent-to-worker enqueue, worker dispatch, worker-to-parent enqueue, host wake, and parent dispatch phases so a failure identifies the missing transition.
  3. Fix the generic Worker lifecycle/scheduling owner found by the reduced test. Preserve complete retirement of pre-navigation workers and ports.
  4. Do not add Code OSS-specific behavior or a longer product timeout.

Gates

Acceptance

The unchanged packaged workbench completes its Monaco Worker request/reply before and after one same-origin reload, retains responsive UI scheduling, and introduces no application patch or browser/WebView dependency.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingvscode-oss/plannedPlanned for the AppScene/WebScene VS Code OSS integration

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions