Skip to content

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

Open
vdusek wants to merge 5 commits into
masterfrom
fix/streamed-log-empty-start
Open

vdusek wants to merge 5 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 at all. That made the integration test call({ log: "default" }) streams the run log to the console while the run executes fail now and then in CI (4 times so far, each green on retry).

The API answers GET /logs/:id?stream=1 with an empty 200 and closes it right away when the run hasn't written its first line yet (apify-core src/api/src/routes/logs/log.ts). StreamedLog opened the stream once, right after start(), so it took that empty response as the whole log. Hitting the API directly reproduced it in 1 of 20 freshly started apify/hello-world runs.

StreamedLog now reopens a stream that ended without any bytes, after a 500 ms pause that stop() cuts short. If stop() comes before anything has arrived, including while a reopened stream is still connecting, it reads the log once with a plain get(). A run that finishes quickly still gets its whole log redirected, and a stream opened during stop() can't cut it off after the first chunk.

Tests cover five cases, each one also in apify/apify-client-python#1084:

  • the first stream is empty, so the log has to come through the reopened one (getStreamedLog())
  • every stream stays empty until the run finishes, so stop() reads the whole log (call())
  • stop() lands while the reopened stream is connecting
  • a missing log is neither reopened nor read
  • a failing one-shot read is logged and stop() still resolves

The first three fail without the fix. The live integration test passed 30 of 30 runs afterwards.

The Python client had the same bug: apify/apify-client-python#1084.

✍️ 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/37321221161#summary-111800489211

@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

This branch has not been deployed

No deployments
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