fix: apply the client timeout to reading, not just connecting - #8
Merged
Conversation
HomeDepotTest failed 4 of the last 7 CI runs, always the same way: SerpApiException: java.net.http.HttpTimeoutException: request timed out SerpApi.timeout was wired only to setHttpConnectionTimeout, so the read timeout was never configured and kept SerpApiHttp's 60s default. That is backwards: a 60s connection timeout is meaningless, since connecting takes milliseconds, while 60s to read is tight for engines that scrape. Apply the timeout to both, and raise the default to 120s, which the home_depot engine regularly needs. This is a library fix rather than a test fix: any caller searching a slow engine hit the same timeout. Also repair the README snippet helper, which sliced examples at a hardcoded lines[23..], assuming every example body starts at line 24. Quarantining GoogleEventsTest shifted that file and pulled the @ignore and its comment into the docs as if they were usage code. Anchor on the "// setup serpapi client" marker instead, which every example test has exactly once, and regenerate. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Created accidentally by a shell redirect run from the wrong directory. Co-Authored-By: Claude Opus 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.
Why CI keeps failing
HomeDepotTesthas failed 4 of the last 7 runs, always identically:Not flake in the usual sense, and nothing to do with the recent error-handling or markdown work — the
home_depotengine intermittently takes longer than a minute, and the request is cut off at 60s.Root cause
SerpApi.timeoutwas applied to one timeout only:So the read timeout — the one actually expiring — was never configured and kept
SerpApiHttp's own 60s default. That is backwards: a 60s connection timeout is meaningless, since connecting takes milliseconds, while 60s to read is tight for engines that scrape.Change
Apply the timeout to both, and raise the default to 120s.
This is a library fix, not a test fix. Any caller searching a slow engine hit the same wall, and
setHttpReadTimeoutexisted but nothing wired it up. The only behavioral change for users is that a hung request now waits 120s instead of 60s before failing; anyone wanting the old bound can still settimeoutthemselves.TimeoutTestcovers both halves and runs offline.Also: the README generator was broken
snippetinREADME.md.erbsliced examples at a hardcodedlines[23..stop-1], assuming every example body starts at line 24. QuarantiningGoogleEventsTestshifted that file, so regenerating pulled the@Ignoreand its explanation into the docs as if they were usage code:Now anchored on the
// setup serpapi clientmarker, which every one of the 21 example tests has exactly once. README regenerated: the google_events example is correct again, and a stray blank line in the google play example is gone.Verification
Offline tests pass locally. The real check is whether
HomeDepotTeststays green across CI runs — one green run does not prove much given it has passed 3 of 7 on its own.🤖 Generated with Claude Code