Skip to content

feat: accept an AbortSignal in resource-client methods - #1081

Open
vdusek wants to merge 2 commits into
v3from
feat/abort-signal
Open

vdusek wants to merge 2 commits into
v3from
feat/abort-signal

Conversation

@vdusek

@vdusek vdusek commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Every method that takes timeoutSecs now also takes signal?: AbortSignal, and forwards it to each request it sends. Once the signal aborts, the request in flight ends, no retry or further poll follows, and the method rejects with the signal's reason. The field sits on TimeoutOptions, so call(), waitForFinish() and the single-request methods all pick it up.

  • The signal never reaches the query string or the body. Methods that spread their remaining options into the params or the getOrCreate() body take it out first.
  • The waits between polls and between batchAddRequests() retries end early on abort. sleep(ms, signal) moved from the HTTP client into utils.ts for that.
  • batchAddRequests() rejects on abort. Its catch otherwise reports the remaining requests as unprocessed and resolves.
  • StreamedLog takes a signal, which call() passes through. Without it, call() with the default log redirection hung after an abort until a quiet run printed its next line.
  • The timeouts concept page has a new "Aborting a call" section.

Tests: a forwarding case for every method in the client_timeouts table, and abort_signal.test.ts, which drives call(), waitForFinish() and batchAddRequests() against a local server.

Closes #1071

✍️ Drafted by Claude Code

@vdusek vdusek added the t-tooling Issues with this label are in the ownership of the tooling team. label Sep 25, 2026
@vdusek vdusek self-assigned this Sep 25, 2026
@github-actions

github-actions Bot commented Sep 25, 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/36116203177#summary-108010787689

@vdusek
vdusek requested a review from janbuchar September 25, 2026 09:12
@vdusek
vdusek marked this pull request as ready for review September 25, 2026 09:12
@vdusek
vdusek requested a review from szaganek as a code owner September 25, 2026 09:12

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

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