Skip to content

Preserve nested IndexedDB transaction tasks through terminal pagehide #882

Closed

Description

@wieslawsoltes

Problem

The exact packaged VS Code OSS acceptance still loses the saved MCP password across window.location.reload() after WebScene #881 (ba71aa1b). The focused #881 fixture passed, but it modeled one timer followed directly by the durable operation. VS Code's real IndexedDB path schedules a nested zero-delay transaction sequence before it calls WebScene's native storage function.

Exact package:

  • AppScene: cd0a02ecd15f0a635bccc242cdd657888db39e25
  • WebScene: ba71aa1b4e832c521b81cb3c252c513412ca2c7f
  • VS Code OSS: 645f29cc3176500b4b5762ba887cf2a7f0ffdf2c
  • executable SHA-256: 6b44ef80282a6f491ba974318ed84fb8c637b6a4d2245f241a4412e7f9b787a4

The first workbench accepts the real password, awaits the upstream MCP interaction, observes encrypted SecretStorage, waits 250 ms, and calls location.reload(). The replacement workbench reports:

{
  "mcpStoredInputKeys": [],
  "mcpStoredInputPresent": false,
  "navigationCount": 2,
  "beforeUnloadCount": 1,
  "pageHideCount": 1,
  "storageRoundTrip": true
}

The package fails after 28.803 s with The real MCP password input did not open. The native persistence probe itself passes, so the defect is isolated to the shutdown-descended transaction chain rather than storage partition selection.

Root-cause direction

VS Code Storage.flush(0) starts through a zero-delay ThrottledDelayer. Its callback opens an IndexedDB transaction. WebScene's compatibility transaction then uses nested zero-delay tasks for:

  1. transaction finish scheduling,
  2. object-store request execution,
  3. final commit scheduling,
  4. __webSceneIndexedDBStorage('store', ...) and its completion.

The terminal handoff must retain this entire causally descended bounded chain until the native store completion settles, then dispatch pagehide, then expose reload. The current focused fixture does not reproduce all these intermediate timers and transaction event callbacks, so it can pass while the unchanged VS Code path loses mcpInputs.

Proposed implementation

  • Add an exact native regression using the public indexedDB compatibility surface and the same nested transaction pattern as VS Code's IndexedDB.runInTransaction.
  • Record terminal-critical ancestry across every zero-delay transaction task and native IndexedDB completion, including promise/microtask continuations created by those tasks.
  • Keep the existing 1,024-task bound and exclude intervals, animation frames, positive-delay tasks, and unrelated work.
  • Dispatch pagehide once only after the chain has no remaining critical timers or native IndexedDB operations; expose reload afterward.
  • Restart the engine and assert the stored mcpInputs-shaped record is durable.

Acceptance

  • The exact native regression proves the order beforeunload -> flush timer -> transaction tasks -> native commit -> transaction complete -> pagehide -> reload and restarted durable read.
  • Existing terminal budget/non-starvation tests pass.
  • The exact package smoke reports mcpStoredInputPresent: true, reopens the prefilled real password input, and passes.

Activity

  1. added
    bug
    vscode-oss/planned
    on Sep 20, 2026
  2. added
    vscode-oss/merged
    and removed
    vscode-oss/planned
    on Sep 20, 2026
  3. wieslawsoltes commented on Sep 20, 2026

    @wieslawsoltes
    CollaboratorAuthor

    Merged in #883 at 2520661b599b8f6f0b9996967bbee816451c0e85. The refined root cause was an IndexedDB compatibility transaction already queued before terminal navigation, rather than only a transaction descended from lifecycle. The focused macOS arm64 Release regression now proves both the pre-existing write and lifecycle write complete before pagehide, survive engine restart, and preserve the existing 1,024-task bound; it passed in 0.0037 s. Exact packaged Code OSS validation is next.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugvscode-oss/merged

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions