Repository navigation
Description
Parent: #269
Release acceptance epic: #227
Problem
A top-level reload/navigation can reach the native host after the first zero-delay tasks queued by beforeunload/pagehide, while persistence work descended from those tasks is still active.
The exact unchanged Code OSS Release package at AppScene cd0a02e / WebScene a7943723 demonstrates the failure:
- VS Code accepts and encrypts an MCP input.
IStorageService.flush(SHUTDOWN)firesonWillSaveState.- Its browser storage layer schedules the workspace
mcpInputsIndexedDB transaction. - WebScene runs the first lifecycle timer, then publishes reload.
- AppScene replaces the realm before descendant transaction timers and the native IndexedDB load/store completion chain finish.
- The second workbench retains the encrypted secret provider but has no
mcpInputsmetadata, and upstreameditStoredInputfails while reading the missing entry.
PR #877 correctly established the first browser-task boundary. It intentionally excludes timers created by those timers to prevent an arbitrary self-refilling timer from starving navigation. That bound is too shallow for browser persistence, whose transaction contract necessarily spans descendant zero-delay tasks and native async completion.
Proposed runtime contract
- Tag non-repeating zero-delay tasks scheduled by terminal lifecycle listeners, their microtasks, or an already tagged task.
- Propagate that tag into native IndexedDB operations started by the task and through their Promise continuations.
- Keep only the terminal reload/navigation host request private while tagged persistence work is pending.
- Publish the request immediately after tagged timers and IndexedDB operations drain.
- Do not wait for unrelated timers, intervals, animation frames, or pre-existing IndexedDB operations.
- Preserve bounded host-request capacity, FIFO order, recursive-navigation coalescing, veto/error cleanup, and task-source fairness.
Acceptance
- An IndexedDB write scheduled from
beforeunloadthrough a zero-delay task is durable before the native reload request becomes visible. - A native IndexedDB load/store completion and its Promise continuation remain inside the terminal persistence boundary.
- A nested zero-delay task in that continuation is included.
- Unrelated/future/repeating timers do not delay navigation.
- Vetoed and failed lifecycle paths publish no host request and leak no reservations or tagged work.
- Reload and same-origin navigation preserve FIFO order and exact-once lifecycle dispatch.
- Focused Release regression covers durable restart visibility and a bounded 1,000-request performance lane.
- Rebuilt unchanged Code OSS Release completes the two-realm MCP persistence smoke.
Evidence
Exact retained artifact:
vscode-demo/artifacts/smoke-cd0a02e-a7943723-mcp-retry/native-smoke.json
The second realm reports navigation count 2, first beforeunload/pagehide, no IndexedDB conflict, and then TypeError: Cannot read properties of undefined (reading 'value') because the stored MCP input record is absent.
Activity