-
Notifications
You must be signed in to change notification settings - Fork 2
Updated cancellation documentation with detailed behavior and examples #49
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
base: main
Are you sure you want to change the base?
Conversation
For cancellation to work, the invocation must reach the deployment (the service endpoint must be reachable). | ||
|
||
If the deployment is not reachable, cancellation will not work. In this case, use [kill](#kill) instead. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could be made shorter in a single sentence
The cancellation exception (`TerminalError` in TypeScript/Python, `TerminalException` in Java/Kotlin) is thrown at the next **await point** - operations that wait for a result: | ||
- Run actions: `ctx.run()` | ||
- Request-response calls | ||
- Sleep | ||
- Awakeable resolution | ||
- Promise combinators (e.g., `RestatePromise.all()`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to enumerate them all, as they might change.
The cancellation exception (`TerminalError` in TypeScript/Python, `TerminalException` in Java/Kotlin) is thrown at the next **await point** - operations that wait for a result: | |
- Run actions: `ctx.run()` | |
- Request-response calls | |
- Sleep | |
- Awakeable resolution | |
- Promise combinators (e.g., `RestatePromise.all()`) | |
The cancellation exception (`TerminalError` in TypeScript/Python, `TerminalException` in Java/Kotlin) is thrown at the next **await point** - operations that wait for a result, such as `ctx.run()`, call responses, sleeps, awakeable results, etc. |
Operations that are **not** await points will continue to execute and ignore cancellation: | ||
- Setting and getting state | ||
- Sending messages / one-way calls | ||
- Delayed messages | ||
- Deterministic UUID generation with the context (e.g., `ctx.uuid()`) | ||
- Other non-blocking context operations |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one too is too much detailed IMO, plus wrong, get state is an await point. Just remove it.
Operations that are **not** await points will continue to execute and ignore cancellation: | |
- Setting and getting state | |
- Sending messages / one-way calls | |
- Delayed messages | |
- Deterministic UUID generation with the context (e.g., `ctx.uuid()`) | |
- Other non-blocking context operations |
1. **Propagate to leaves**: Cancellation first reaches the leaves of the call graph | ||
2. **Throw at await points**: Each handler receives the cancellation exception at its next await point | ||
3. **Run compensation**: Handlers execute their compensation logic (if defined) | ||
4. **Propagate upward**: Cancellation flows back up the call graph, allowing each parent to compensate |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not fully right, and I think misleading written this way. The automatic propagation is only to leaves, and not to parents. the cancellation propagates upward if the user rethrows the error manually, or doesn't catch the exception, which btw is correct terminology really only in languages with exceptions/automatic error propagation, it doesn't apply to go and rust for example.
I would be prone to remove this line completely. It's clear enough that it throws an error.
Clarified cancellation requirements, flow, and behavior based on Slack discussion. Added code example showing when cancellation exceptions are thrown at await points.
Created by Mintlify agent