Repository navigation
fix: clamp timeouts longer than setTimeout allows instead of panicking - #122
Open
QuantumExplorer wants to merge 1 commit into
Open
QuantumExplorer wants to merge 1 commit into
QuantumExplorer wants to merge 1 commit into
Conversation
AbortGuard::timeout converted the timeout to an i32 number of milliseconds with expect(), so any timeout above i32::MAX ms (about 24.8 days), such as Duration::MAX used to mean "no timeout", panicked with "timeout: TryFromIntError(PosOverflow)" on the first call. setTimeout's delay is a signed 32-bit number and browsers fire at once for a larger one, so a longer timeout is now clamped to i32::MAX ms. Fixes devashishdxt#108 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Fixes #108.
Problem
AbortGuard::timeoutconverts the timeout to ani32number of milliseconds withexpect(), so anyFetchOptions::timeoutabovei32::MAXms (about 24.8 days), such asDuration::MAXused to mean "no timeout", panics on the first call withtimeout: TryFromIntError(PosOverflow). #108 has a reproduction.Fix
A new
timeout_millisclamps the delay toi32::MAXms.setTimeout's delay is a signed 32-bit number and browsers fire at once for a larger one, so a longer delay cannot be passed through.Before and after
FetchOptions::timeouti32::MAXmsDuration::MAXtimeout: TryFromIntError(PosOverflow)Tests
Unit test
timeout_is_clamped_to_the_largest_set_timeout_delayinsrc/abort_guard.rs. I also ran the reproduction from #108, a call withDuration::MAX, which panicked before and succeeds with this change.cargo fmt --check,cargo clippy --all-targets -- -D warnings,cargo clippy --target wasm32-unknown-unknown -- -D warningsandcargo testare clean, and the browser suite intest-suite/simplepasses in headless Chrome 153.This is one of 14 PRs from the review asked for in #97. They are independent, and all 14 also merge together cleanly; with all of them merged, both browser suites (
test-suite/simpleandtest-suite/gzip) pass.🤖 Generated with Claude Code