Skip to content

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

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

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

Conversation

@vdusek

@vdusek vdusek commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

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

@vdusek vdusek self-assigned this Oct 2, 2026
@apify-service-account apify-service-account added tested Temporary label used only programatically for some analytics. t-tooling Issues with this label are in the ownership of the tooling team. labels Oct 2, 2026
@github-actions

github-actions Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ There are broken links in the documentation.

See more at https://github.com/apify/apify-client-js/actions/runs/37913067559#summary-113762596216

@vdusek vdusek added the adhoc Ad-hoc unplanned task added during the sprint. label Oct 2, 2026
@vdusek
vdusek requested a review from Pijukatel October 2, 2026 09:47
Comment thread src/resource_clients/log.ts Outdated
@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 added a commit to apify/apify-client-python that referenced this pull request Oct 9, 2026
…1084)

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 merged commit b79b5e5 into master Oct 9, 2026
10 checks passed
@vdusek
vdusek deleted the fix/streamed-log-empty-start branch October 9, 2026 09:47
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.

3 participants