Skip to content

fix: redirect the run log when the first log stream comes back empty - #1084

Merged
vdusek merged 12 commits into
masterfrom
fix/streamed-log-empty-start
Oct 9, 2026
Merged

vdusek merged 12 commits into
masterfrom
fix/streamed-log-empty-start

Conversation

@vdusek

@vdusek vdusek commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Python twin of apify/apify-client-js#1105.

call(logger=...) and get_streamed_log() sometimes redirected no log lines. Before a run writes its first line, the API answers GET /logs/:id?stream=1 with an empty 200 that closes at once, and StreamedLog / StreamedLogAsync took that as the whole log.

Both now reopen an empty stream after a pause that starts at 0.5 s and doubles up to 5 s. If stop() comes before anything has arrived, they read the log once with get_as_bytes(). start() resets that state, so a restarted instance behaves the same.

Tests cover the same cases as #1105 for both classes and both HTTP clients, plus the backoff and a restart.

✍️ Drafted by Claude Code

@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 Oct 2, 2026
@vdusek vdusek self-assigned this Oct 2, 2026
@vdusek
vdusek requested a review from Pijukatel October 2, 2026 09:58
@codecov

codecov Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.59155% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 95.53%. Comparing base (9325530) to head (d43fcdb).
⚠️ Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
src/apify_client/_streamed_log.py 98.59% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1084      +/-   ##
==========================================
+ Coverage   95.41%   95.53%   +0.11%     
==========================================
  Files          61       61              
  Lines        5894     5935      +41     
==========================================
+ Hits         5624     5670      +46     
+ Misses        270      265       -5     
Flag Coverage Δ
integration 90.93% <71.83%> (-0.11%) ⬇️
unit 88.94% <98.59%> (+0.26%) ⬆️

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 marked this pull request as ready for review October 2, 2026 10:01
@apify-service-account apify-service-account added the tested Temporary label used only programatically for some analytics. label Oct 2, 2026
@vdusek
vdusek requested a review from Mantisus October 7, 2026 09:23
Comment thread src/apify_client/_streamed_log.py Outdated
Comment thread src/apify_client/_streamed_log.py

@Mantisus Mantisus left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@apify-approval-mirror apify-approval-mirror Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mirroring approval from @Mantisus.

@vdusek vdusek changed the title fix(log): redirect the run log when the first log stream comes back empty fix: redirect the run log when the first log stream comes back empty Oct 9, 2026
@vdusek
vdusek merged commit a370e7a into master Oct 9, 2026
30 of 31 checks passed
@vdusek
vdusek deleted the fix/streamed-log-empty-start branch October 9, 2026 09:47
vdusek added a commit to apify/apify-client-js that referenced this pull request Oct 9, 2026
…1105)

`call({ log })` and `run.getStreamedLog()` sometimes redirected no log
lines, which made the `call({ log: "default" })` integration test flaky.
Before a run writes its first line, the API answers `GET
/logs/:id?stream=1` with an empty 200 that closes at once (about 1 in 20
fresh `apify/hello-world` runs), and `StreamedLog` took that as the
whole log.

`StreamedLog` now reopens an empty stream after a pause that starts at
500 ms and doubles up to 5 s. If `stop()` comes before anything has
arrived, it reads the log once with `get()`. This also covers a stream
still connecting when the `stop()` grace period ends.

Tests cover the same cases as apify/apify-client-python#1084, plus the
backoff and the grace-period fallback.

*✍️ Drafted by Claude Code*
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.

4 participants