Skip to content

billingFacadeConsumers rail regression is time-dependent after the boot double-fetch #14742

Description

@christian-byrne

Residual from the review of #14614. Non-blocking, test reliability.

The rail-selection regression in browser_tests/tests/billingFacadeConsumers.spec.ts is correct as written (the checkout_type and counter-reset fixes both landed), but it is time-dependent in both directions, and the rail-synchronisation change widened the window.

Boot now issues at least two /api/billing/status requests rather than one:

  1. billingRailByWorkspaceId starts empty (teamWorkspaceStore.ts, the only writer is setWorkspaceBillingRail), so at boot the rail is undefined and useBillingRouting resolves to workspace
  2. the workspace adapter fetches status and writes legacy_stripe
  3. type flips to legacy, useBillingContext tears down and rebuilds, and the newly built useSubscription fetches again

bootApp only waits for window.app?.extensionManager, so nothing awaits the settlement of either fetch. Two failure modes follow:

  • a late boot fetch can satisfy expect.poll(() => billingRequests.workspaceStatus).toBeGreaterThan(0) on its own, so the test greens without the recovery path running
  • the in-flight coalescer can swallow the recovery fetch entirely, so the poll times out and the test flakes red

Suggested: await a settled rail (or a stable request count) before the billingRequests.workspaceStatus = 0 reset, so the poll measures only the recovery fetch.

Thread: #14614 (comment)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions