Repository navigation
Use wall-clock time for staging IAP token expiry - #17016
Merged
Merged
Conversation
On macOS, `Instant` does not advance while the system sleeps, so the `Instant`-based IAP token expiry outlived the real token after a sleep. The client then attached an expired token and IAP returned "OpenID Connect token expired: JWT has expired". Store the expiry as `SystemTime` from the JWT `exp` claim, and re-arm the IAP refresh when the system wakes, because refresh timers are also late by the sleep duration. Co-Authored-By: Warp <agent@warp.dev>
Co-Authored-By: Warp <agent@warp.dev>
Co-Authored-By: Warp <agent@warp.dev>
Co-Authored-By: Warp <agent@warp.dev>
Co-Authored-By: Warp <agent@warp.dev>
IsaiahWitzke
marked this pull request as ready for review
November 30, 2026 19:21
IsaiahWitzke
enabled auto-merge (squash)
November 30, 2026 19:22
harryalbert
approved these changes
Nov 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Local staging builds sometimes fail an agent request with
ErrorStatus(401, "OpenID Connect token expired: JWT has expired"). IAP returns this error when the client sends an expired IAP token.Root cause:
CachedToken.expires_atwas anInstant. On macOS,InstantusesCLOCK_UPTIME_RAW, and that clock stops while the system sleeps. After a sleep, the cache counted the token as valid even when its JWTexphad passed, soIapState::get_cachedattached the expired token.Changes:
CachedToken.expires_atis now aSystemTimefrom the JWTexpclaim. Validity checks, the refresh schedule, the on-disk WIF cache, and the settings widget now use wall-clock time.IapManager::handle_system_wakere-arms the refresh onSystemStatsEvent::CpuWasAwakened. Refresh timers also stop during sleep, so the wake handler fixes a late refresh. If the token is near expiry, the refresh starts immediately.Reading order:
crates/warp_server_client/src/iap.rs, then the wake subscription inapp/src/lib.rs.Linked Issue
None.
Testing
cargo nextest run -p warp_server_client iap: 33 tests pass. Existing tests now useSystemTime, and two new tests cover the wake handler.cargo clippy -p warp_server_client -p warp --all-targets --tests -- -D warnings: clean.Agent Mode
Conversation: https://staging.warp.dev/conversation/ac8551f7-4525-46a3-80ae-152870de18f6
CHANGELOG-NONE
Co-Authored-By: Warp agent@warp.dev