Skip to content

Cap lookup time across fallback drivers and expose driver failures - #412

Open
tegos wants to merge 1 commit into
stevebauman:masterfrom
tegos:fix/lookup-timeout-budget
Open

Cap lookup time across fallback drivers and expose driver failures#412
tegos wants to merge 1 commit into
stevebauman:masterfrom
tegos:fix/lookup-timeout-budget

Conversation

@tegos

@tegos tegos commented Aug 16, 2026

Copy link
Copy Markdown

Closes #182.

http.timeout is per driver, not per lookup. With the shipped config (IpApi plus four fallbacks) an unreachable provider costs that timeout five times over, so Location::get() in #182 returned false after ~16s with timeout => 3. Reproduced against a socket that accepts but never responds: 15.71s currently, 4.04s with total_timeout => 4.

HttpDriver also swallowed every exception via rescue(..., false, false), so nothing explained the delay.

Two changes:

  1. total_timeout (default null, so nothing changes unless set) gives the whole lookup one budget. Each driver's timeout is capped to what's left, and drivers with no time left aren't called.

  2. LookupFailed event carrying driver, ip and exception. Kept off the log on purpose, since a failing driver is normal when fallbacks are configured and Ignore Report #144 deliberately turned reporting off. throw_if($response->failed()) became $response->throw(), so the event carries a RequestException with the status and body instead of a bare RuntimeException.

Your call: total_timeout defaults to null for compatibility, which means #182's config still takes ~15s. Happy to default it to a number instead.

Each driver got its own timeout, so the shipped config (one driver plus
four fallbacks) took five times `http.timeout` before returning false,
and HttpDriver swallowed every exception without reporting it.

Refs stevebauman#182
@tegos

tegos commented Aug 20, 2026

Copy link
Copy Markdown
Author

Hey @stevebauman, any chance you could take a look at this when you have a moment? No rush.

Heads up that CI hasn't run yet, it needs an approval since it's my first PR here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Timeout settings

1 participant