Skip to content

perf: optimize step boundary cancellation check#41

Merged
coji merged 1 commit into
mainfrom
perf/step-boundary-cancel-check
Mar 4, 2026
Merged

perf: optimize step boundary cancellation check#41
coji merged 1 commit into
mainfrom
perf/step-boundary-cancel-check

Conversation

@coji
Copy link
Copy Markdown
Owner

@coji coji commented Mar 4, 2026

Summary

  • Check controller.signal.aborted (in-memory) before storage.getRun() (DB query) at step boundaries
  • When cancellation is detected via the run:cancel event, the DB query is skipped entirely
  • Also adds signal check before replaying cached steps during resume, improving cancellation responsiveness for jobs with many completed steps
  • DB fallback is preserved for edge cases (e.g., run cancelled while worker was down)

Changes

  • packages/durably/src/context.ts: Add fast-path signal checks before DB queries

Test plan

  • pnpm --filter durably test:node passes (186 tests)
  • Existing cancellation tests cover both signal-based and DB-based cancellation paths

Fixes #38

🤖 Generated with Claude Code

Check controller.signal.aborted before falling back to the DB query
at step boundaries. This skips the storage.getRun() call when
cancellation was already detected via the run:cancel event listener.

Also adds a signal check before replaying cached steps, making
cancellation more responsive during resume of jobs with many
completed steps.

Fixes #38

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented Mar 4, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
durably-demo Ready Ready Preview Mar 4, 2026 2:51pm

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 4, 2026

Warning

Rate limit exceeded

@coji has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 5 minutes and 16 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 547d5cd6-b4f6-4b1c-b317-6758184c7edf

📥 Commits

Reviewing files that changed from the base of the PR and between ac817a9 and f9772bb.

📒 Files selected for processing (1)
  • packages/durably/src/context.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch perf/step-boundary-cancel-check

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coji coji merged commit ac4f439 into main Mar 4, 2026
4 checks passed
@coji coji deleted the perf/step-boundary-cancel-check branch March 5, 2026 12:14
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.

perf: optimize step boundary cancellation check

1 participant