Skip to content

Fix/http client bounded parallelism - #140

Merged
kanimaru merged 2 commits into
masterfrom
fix/http-client-bounded-parallelism
Sep 8, 2026
Merged

Fix/http client bounded parallelism#140
kanimaru merged 2 commits into
masterfrom
fix/http-client-bounded-parallelism

Conversation

@kanimaru

@kanimaru kanimaru commented Sep 8, 2026

Copy link
Copy Markdown
Owner

Related to #130

Restore the old contract of BufferedHttpClient with configurable parallism. Best of both worlds.

closes #130

GustavoLR548 and others added 2 commits September 8, 2026 09:06
- Implement sequential request dispatching with a queue-based approach to ensure requests are processed one at a time.
- Add traffic logging feature to diagnose stalls and timeouts.
- Improvements include: tracking request dispatch timing, null-safety check in queue_free(), fixed retry logic to properly manage current_request state, and a _log_traffic() helper for timestamped diagnostics.
…ncing

Builds on #130 which correctly identified that several threaded HTTPRequests
started in the same frame can stall and time out, but strict one-at-a-time
dispatch also serialized emote and badge image downloads, which is what the
parallel behaviour existed for.

- BufferedHTTPClient gets `max_parallel_requests` (default 1, 0 = unlimited).
  Requests wait in `queued_requests` and move to `active_requests` in order as
  slots free up. API and OAuth clients stay sequential.
- TwitchMediaLoader exports `max_parallel_downloads` (default 8) and applies it
  to its own client, so image downloads keep overlapping.
- Retries keep their slot, rebind the RequestData (not the new node) and free
  the failed attempt's HTTPRequest. Exhausted retries and a failing
  HTTPRequest.request() now deliver an error response instead of hanging
  waiters and blocking the slot forever.
- `request_timeout` is exported; the "request done" log line reports duration
  and retry count, replacing the separate `log_traffic` toggle.
- Removes the unused `current_request`, `current_response_data`, `error_count`
  and `polling` fields.
- Adds a GUT suite that drives the client against a loopback HTTPServer.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@kanimaru kanimaru self-assigned this Sep 8, 2026
@kanimaru kanimaru added bug Something isn't working enhancement New feature or request labels Sep 8, 2026
@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown

GUT Results

132 tests  +6   132 ✅ +6   2s ⏱️ +2s
 10 suites +1     0 💤 ±0 
  1 files   ±0     0 ❌ ±0 

Results for commit db5adca. ± Comparison against base commit a56c985.

@kanimaru
kanimaru merged commit 7a732b1 into master Sep 8, 2026
4 checks passed
@kanimaru
kanimaru deleted the fix/http-client-bounded-parallelism branch September 8, 2026 07:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants