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:
billingRailByWorkspaceId starts empty (teamWorkspaceStore.ts, the only writer is setWorkspaceBillingRail), so at boot the rail is undefined and useBillingRouting resolves to workspace
- the workspace adapter fetches status and writes
legacy_stripe
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)
Residual from the review of #14614. Non-blocking, test reliability.
The rail-selection regression in
browser_tests/tests/billingFacadeConsumers.spec.tsis correct as written (thecheckout_typeand 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/statusrequests rather than one:billingRailByWorkspaceIdstarts empty (teamWorkspaceStore.ts, the only writer issetWorkspaceBillingRail), so at boot the rail is undefined anduseBillingRoutingresolves toworkspacelegacy_stripetypeflips tolegacy,useBillingContexttears down and rebuilds, and the newly builtuseSubscriptionfetches againbootApponly waits forwindow.app?.extensionManager, so nothing awaits the settlement of either fetch. Two failure modes follow:expect.poll(() => billingRequests.workspaceStatus).toBeGreaterThan(0)on its own, so the test greens without the recovery path runningSuggested: await a settled rail (or a stable request count) before the
billingRequests.workspaceStatus = 0reset, so the poll measures only the recovery fetch.Thread: #14614 (comment)