Skip to content

fix: offload async request body compression to a worker thread#950

Open
vdusek wants to merge 1 commit into
masterfrom
fix/offload-request-compression
Open

fix: offload async request body compression to a worker thread#950
vdusek wants to merge 1 commit into
masterfrom
fix/offload-request-compression

Conversation

@vdusek

@vdusek vdusek commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

The async ImpitHttpClientAsync.call() serialized and compressed request bodies inline on the event loop. Compression is CPU-bound (and brotli is becoming the default via the Apify SDK), so it blocked the loop for the whole duration of the compression, stalling every other concurrent task (response reads, the platform events websocket, other in-flight requests).

Request preparation is now offloaded to a worker thread via asyncio.to_thread whenever there is a body to compress. Bodyless requests (the common polling, listing, and get path) stay inline to avoid a needless thread-dispatch hop. The synchronous client is unchanged, as it has no event loop to block.

@vdusek vdusek added adhoc Ad-hoc unplanned task added during the sprint. t-tooling Issues with this label are in the ownership of the tooling team. labels Jul 16, 2026
@vdusek vdusek self-assigned this Jul 16, 2026
@github-actions github-actions Bot added this to the 145th sprint - Tooling team milestone Jul 16, 2026
@github-actions github-actions Bot added the tested Temporary label used only programatically for some analytics. label Jul 16, 2026
@codecov

codecov Bot commented Jul 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.60%. Comparing base (a8a393b) to head (5e7f697).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #950      +/-   ##
==========================================
- Coverage   94.61%   94.60%   -0.02%     
==========================================
  Files          58       58              
  Lines        5239     5241       +2     
==========================================
+ Hits         4957     4958       +1     
- Misses        282      283       +1     
Flag Coverage Δ
integration 92.38% <100.00%> (-0.29%) ⬇️
unit 83.74% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@vdusek
vdusek requested a review from Pijukatel July 16, 2026 12:15
@vdusek
vdusek marked this pull request as ready for review July 16, 2026 12:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

adhoc Ad-hoc unplanned task added during the sprint. t-tooling Issues with this label are in the ownership of the tooling team. tested Temporary label used only programatically for some analytics.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants