01Mmedconf 85%
Potential race condition: drain listener fires before state is updated
src/main/rate-limits/service.ts:490
The drain listener registered in index.ts calls rateLimits?.refreshAfterClaudeLivePtysDrained(). This method checks this.state.claude?.usageMetadata?.deferredByLiveClaudeSession. However, the drain notification is fired synchronously from markClaudePtyExited or confirmSeededClaudeLivePtys, which may occur before the rate limit service has fetched the deferred state (e.g., on startup, if the deferred state is loaded asynchronously). If the drain fires before the initial refresh completes, the guard deferredByLiveClaudeSession will be false, and the refetch will be skipped, leaving the UI stuck on 'Waiting for Claude session'.