-
Notifications
You must be signed in to change notification settings - Fork 141
chore(docs): document abort signal #3673
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
chore(docs): document abort signal #3673
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
2 Skipped Deployments
|
|
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
How to use the Graphite Merge QueueAdd the label merge-queue to this PR to add it to the merge queue. You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
PR Review: Document Abort SignalOverviewThis PR adds documentation for the abort signal feature in Rivet Actors, covering both automatic cleanup on actor shutdown and manual cancellation of long-running operations. Code Quality & Documentation ✅Strengths:
Suggestions for Improvement1. Expand the Manual Cancellation Example (actions.mdx:248-280)The current example shows chaining Issue: The custom controller stored in Suggestion: Consider adding a note about this limitation or showing a more robust pattern for handling multiple concurrent operations, or add a comment explaining the single-operation assumption. 2. Add Error Handling Guidance (actions.mdx:248-280)When an 3. Clarify Timing of
|
e5f8ece to
90b596c
Compare
8365103 to
4072138
Compare
4072138 to
ee5f7b8
Compare
90b596c to
4c79885
Compare
ee5f7b8 to
9f0dc33
Compare
4c79885 to
479a600
Compare
479a600 to
4c79885
Compare
9f0dc33 to
ee5f7b8
Compare
PR Review: Document Abort SignalSummaryThis PR adds documentation for the abort signal feature in Rivet Actors, covering both automatic shutdown cancellation and manual cancellation patterns. The additions are well-structured and provide clear examples for both use cases. ✅ StrengthsClear Documentation Structure
Practical Examples
Consistent with Project Style
🔍 Issues & Suggestions1. Potential Race Condition in Manual Cancellation ExampleLocation: const controller = new AbortController();
c.vars.controller = controller;
c.abortSignal.addEventListener("abort", () => controller.abort());Issue: There's a subtle race condition here. If the actor is already shutting down when this action starts, Recommendation: Check if the signal is already aborted: const controller = new AbortController();
c.vars.controller = controller;
// Handle both cases: already aborted or will abort
if (c.abortSignal.aborted) {
controller.abort();
} else {
c.abortSignal.addEventListener("abort", () => controller.abort());
}2. Missing Error Handling in ExamplesLocations:
Issue: The fetch examples don't handle abort errors. When an abort signal fires, fetch throws an Recommendation: Add error handling to show best practices: try {
const response = await fetch("https://api.example.com/generate", {
method: "POST",
body: JSON.stringify({ prompt }),
signal: c.abortSignal
});
return await response.json();
} catch (error) {
if (error.name === 'AbortError') {
// Operation was cancelled, this is expected
return null; // or throw a UserError if appropriate
}
throw error; // Re-throw other errors
}3. Vars Type Definition Could Be More ExplicitLocation: createVars: () => ({ controller: null as AbortController | null }),Minor Issue: While this works, it's slightly redundant. Consider simplifying to: createVars: () => ({ controller: null as AbortController | null }),
// Could be:
createVars: (): { controller: AbortController | null } => ({ controller: null }),This is more explicit about the return type and follows the pattern used elsewhere in lifecycle.mdx (e.g., line 104). 4. Missing Context About When Abort Signal FiresLocation: Issue: The section says "when the actor is stopping" but doesn't clarify what events trigger this:
Recommendation: Add a brief clarification: The `c.abortSignal` provides an `AbortSignal` that fires when the actor is stopping (during sleep, destroy, or server shutdown). Use this to cancel ongoing operations gracefully.📊 Test CoverageStatus: N/A (Documentation only) No tests needed for documentation changes, but consider:
🔒 Security ConsiderationsStatus: ✅ Good
⚡ Performance ConsiderationsStatus: ✅ Good
📝 Minor Suggestions
✅ Overall AssessmentThis is a solid documentation addition that fills an important gap. The examples are clear and the cross-references make it easy for users to find the right pattern for their use case. With the minor improvements suggested above (particularly the race condition fix and error handling), this will be excellent documentation. Recommendation: Approve with suggested improvements for error handling and race condition handling. Generated by Claude Code - Code review based on Rivet project standards and best practices |
ee5f7b8 to
9f0dc33
Compare
4c79885 to
479a600
Compare
9f0dc33 to
ee5f7b8
Compare
4c79885 to
d00a210
Compare
ee5f7b8 to
ba521fc
Compare
d00a210 to
a115757
Compare
ba521fc to
0c18a0d
Compare
0c18a0d to
7b5297c
Compare
a115757 to
25fdb27
Compare
Merge activity
|
25fdb27 to
a0699e3
Compare
7b5297c to
59e5e07
Compare

No description provided.