Skip to content

feat: stream the run log in Actor.call_task - #1275

Merged
vdusek merged 7 commits into
masterfrom
feat/call-task-log-streaming
Nov 27, 2026
Merged

vdusek merged 7 commits into
masterfrom
feat/call-task-log-streaming

Conversation

@vdusek

@vdusek vdusek commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Actor.call_task gets the logger argument that Actor.call already has. By default it redirects the log and the status messages of the task run to the log of the parent Actor. logger=None turns it off, and a custom logger receives the redirected lines.

  • The API client's TaskClient.call cannot redirect the log, so Actor.call_task starts the task with TaskClient.start and waits for the run through the run client. The start request keeps timeout='no_timeout', as in TaskClient.call.
  • A named task call streams the log of a new run from the start, and only the new lines of a reattached run, the same as a named Actor.call.
  • If the redirect cannot be set up, the call logs a warning and waits for the run without its log. The run is already started at that point.
  • Concurrent named calls that share one run redirect its log once. This also holds for a named Actor.call.

Changes for existing Actors:

  • The default is 'default', the same as for Actor.call. So an Actor that calls a task gets the log lines of the task run in its own log.
  • With a logger, Actor.call_task returns about 6 seconds after the run finishes or wait runs out, because the status message redirect of the API client waits that long for the last message. Actor.call has the same delay. Pass logger=None to avoid it.

The JS SDK does not redirect the log of a task run. A logger argument on TaskClient.call in both API clients would be the better place for this, and the SDK would then only pass it on.

The PR is independent of the child runs stack (#1270 and the PRs on top of it). Both change Actor.call_task, so the one that merges second needs a rebase.

✍️ 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 Nov 20, 2026
@vdusek vdusek self-assigned this Nov 20, 2026
@codecov

codecov Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.85%. Comparing base (07d8c19) to head (ee16588).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1275      +/-   ##
==========================================
- Coverage   93.91%   93.85%   -0.06%     
==========================================
  Files          54       54              
  Lines        3893     3906      +13     
==========================================
+ Hits         3656     3666      +10     
- Misses        237      240       +3     
Flag Coverage Δ
e2e 31.05% <13.63%> (-0.03%) ⬇️
integration 50.61% <13.63%> (-0.12%) ⬇️
unit 91.11% <100.00%> (-0.03%) ⬇️

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 November 20, 2026 18:52
@vdusek
vdusek requested a review from szaganek as a code owner November 20, 2026 18:52
@vdusek
vdusek requested review from Pijukatel and removed request for szaganek November 20, 2026 18:52
@Pijukatel

Pijukatel commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Looking at this made me realize we will need some update to the client to properly support memoized child run redirects after migration/reboot/ressurect.

I think client could be updated something like this:

This would allow each memoized child run to also remember timestamp of last redirected log and after migration it would just continue. Currently it either starts from scratch or it misses portion of the log that happened during the reboot/resurrect/migration period.

@Pijukatel Pijukatel left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think this can be merged and later improved in follow ups when client is updated as mentioned.

@vdusek
vdusek merged commit d5f3665 into master Nov 27, 2026
69 of 72 checks passed
@vdusek
vdusek deleted the feat/call-task-log-streaming branch November 27, 2026 09:44
Pijukatel added a commit to apify/apify-client-python that referenced this pull request Nov 27, 2026
- `TaskClient.call` takes the same `logger` as `ActorClient.call`. The
default `'default'` redirects the run's log and status messages, and
`call` returns ~6 s after the run finishes. Pass `logger=None` to opt
out.
- If setting up log redirection fails (for example the token can't read
the Actor), `call` logs a warning and still waits for and returns the
run.
- Merge apify/apify-sdk-python#1275 before releasing this, because
`Actor.call_task` calls `task.call()` without `logger`.
- JS counterpart: apify/apify-client-js#1237

---------

Co-authored-by: Claude <noreply@anthropic.com>
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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants