Skip to content

v3: Cancel awaited subtasks and reliable rate-limit recovery #1200

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Jul 5, 2024

Conversation

ericallam
Copy link
Member

  • When cancelling a task that has in progress or queued subtasks (using triggerAndWait or batchTriggerAndWait), those subtasks will now also be cancelled (and any of their subtasks). Tasks triggered with trigger or batchTrigger will not be cancelled.
  • Changing from sliding window to token bucket in the API rate limiter, to help smooth out traffic
  • Adding spans to the API Client core & SDK functions
  • Added waiting spans when retrying in the API Client
  • Retrying in the API Client now respects the x-ratelimit-reset
  • Retrying ApiError’s in tasks now respects the x-ratelimit-reset
  • Added AbortTaskRunError that when thrown will stop retries
  • Added idempotency keys SDK functions and automatically injecting the run ID when inside a task
  • Added the ability to configure ApiRequestOptions (retries only for now) globally and on specific calls
  • Implement the maxAttempts TaskRunOption (it wasn’t doing anything before)

Copy link

changeset-bot bot commented Jul 4, 2024

🦋 Changeset detected

Latest commit: 202a2fb

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

ericallam added 6 commits July 4, 2024 14:16
- Changing from sliding window to token bucket in the API rate limiter, to help smooth out traffic
- Adding spans to the API Client core & SDK functions
- Added waiting spans when retrying in the API Client
- Retrying in the API Client now respects the x-ratelimit-reset
- Retrying ApiError’s in tasks now respects the x-ratelimit-reset
- Added AbortTaskRunError that when thrown will stop retries
- Added idempotency keys SDK functions and automatically injecting the run ID when inside a task
- Added the ability to configure ApiRequestOptions (retries only for now) globally and on specific calls
- Implement the maxAttempts TaskRunOption (it wasn’t doing anything before)
@ericallam ericallam force-pushed the v3/cancel-run-dependencies branch from df20d43 to edd6342 Compare July 4, 2024 13:16
Copy link
Member Author

@ericallam ericallam left a comment

Choose a reason for hiding this comment

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

self-reviewed 👍

@ericallam
Copy link
Member Author

ericallam commented Jul 4, 2024

  • Add ability to trigger with an idempotency key without the run ID (use optional second param in create)

Comment on lines 107 to 118
const cancelService = new CancelTaskRunService();

// Cancel any dependent task runs
for (const attempt of cancelledTaskRun.attempts) {
for (const dependency of attempt.dependencies) {
await cancelService.call(dependency.taskRun, {
...opts,
reason: `Parent task run was cancelled`,
});
}
}

Copy link
Member

Choose a reason for hiding this comment

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

Should this be here?

@ericallam ericallam merged commit 4f95c9d into main Jul 5, 2024
2 checks passed
@ericallam ericallam deleted the v3/cancel-run-dependencies branch July 5, 2024 09:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants