Skip to content

fix: await connector record persistence before asserting in WebKit test (build fix for vscode-engineering#3992) - #338170

Merged
Joaquín Ruales (jruales) merged 1 commit into
microsoft:mainfrom
vscodebot-pr:fix/connector-recording-test-race-eng3992-aw-36286059070
Sep 27, 2026
Merged

Joaquín Ruales (jruales) merged 1 commit into
microsoft:mainfrom
vscodebot-pr:fix/connector-recording-test-race-eng3992-aw-36286059070

Conversation

@vscodebot-pr

Copy link
Copy Markdown
Contributor

Build failure

The macOS WebKit browser unit test suite failed on a single assertion in CustomizationMarketplaceInstallService:

CustomizationMarketplaceInstallService > Copilot connectors > records a connector that was already connected outside this workbench
actual: recorded=[]; expected: recorded=["mail"]; both state.kind="installed"

The browser exited cleanly (code 0); the runner returned 1 solely for this assertion.

Root cause

The test (records a connector that was already connected outside this workbench) marks a connector as connected, fires the change event, then waits only await timeout(0) before asserting that a record was persisted.

The listener registered in updateEnablement() responds by calling void this.synchronizeConnectedConnectorRecords(). That method computes the record id via createConnectorRecord(), which awaits createInstallationRecordId(...) — an async crypto.subtle.digest('SHA-256', ...) — before calling recordStore.upsert(). A single macrotask (timeout(0)) does not guarantee that the digest promise has resolved and the upsert has run, so on slower/async digest completion the recorded-resource list is still empty when the assertion runs. getInstallState() can return installed directly from the connector's connection status without a stored record, which is why the state assertion passed while recorded was empty. This is a test synchronization defect, not a product regression.

How the fix works

Instead of a fixed timer, the test now waits deterministically for the persistence to complete using the same pattern already established throughout this file (Event.toPromise(Event.filter(service.onDidChange, ...))):

const recorded = Event.toPromise(Event.filter(fixture.service.onDidChange, () => fixture.service.getRecordedResources().some(resource => resource.identifier === 'mail')));
fixture.connectedConnectors.add('mail');
fixture.connectorChanges.fire();
await recorded;

recordStore.upsert() triggers recordStore.onDidChange, which fires the service's onDidChange. The test therefore proceeds only once the connector record is actually persisted, regardless of how long the SHA-256 digest takes. Both original assertions (recorded resources and installed state) are preserved unchanged.

Rollback evaluation

Recommendation: Do not roll back. Public culprit: not confirmed (strong suspect: the commit that introduced the timer-based assertion and async persistence path, #337649, but not verified by reproduction or bisect). Rationale: only one CI assertion is affected and no product data loss is established; a bounded, forward test-synchronization fix is far lower risk than reverting a broad feature with runtime integration. Owners to consult: @pwang347.

Validation

Change is a focused edit to a single test. Repository dependencies were not installed in this environment, so npm-based typecheck/test runs could not be executed here. The edit uses Event/Event.toPromise/Event.filter, all already imported and used repeatedly in this file, and preserves the existing assertions. Recommended local validation: run this suite under WebKit, e.g. npm run test-browser-no-install -- --build --browser webkit filtered to CustomizationMarketplaceInstallService.

Risk

Low. Test-only change; no production code touched. The deterministic wait matches the file's existing idiom and cannot mask a real failure because it still requires the record to be persisted before asserting.

Recommended reviewer

Recommended owner: @pwang347

Fixes microsoft/vscode-engineering#3992

Generated by build-fix · opus48 · 181 AIC · ⌖ 11.9 AIC · ⊞ 9.7K · ◷

Replace the timer-based wait with a deterministic wait on onDidChange
until the connector record is persisted, fixing a flaky assertion race
against SHA-256 record-ID computation.

Co-authored-by: Copilot <[email protected]>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟢 Approval recommended

The focused test-only change correctly eliminates the asynchronous persistence race.

Review effort: Balanced
Findings: None

What changed in this PR

Replaces a timing-dependent test delay with deterministic event-based synchronization.

Changes:

  • Waits until the connector record is observable before asserting.
  • Preserves existing persistence and install-state assertions.
File Description
src/​vs/​workbench/​contrib/​chat/​test/​browser/​aiCustomization/​customizationMarketplaceInstallService.test.ts Synchronizes the connector persistence test with onDidChange.

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@pwang347
Paul (pwang347) marked this pull request as ready for review September 27, 2026 03:51
@jruales
Joaquín Ruales (jruales) merged commit c61fa34 into microsoft:main Sep 27, 2026
36 of 38 checks passed
@vs-code-engineering vs-code-engineering Bot added this to the 1.140.0 milestone Sep 27, 2026
@vs-code-engineering vs-code-engineering Bot locked and limited conversation to collaborators Nov 11, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

vscode-build VS Code build process issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants