feat(workflow-engine): treat undefined loop return as continue for stateless loops#4294
Conversation
|
🚅 Deployed to the rivet-pr-4294 environment in rivet-frontend
|
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: feat(workflow-engine): treat undefined loop return as continue for stateless loopsThe overall approach is solid and well-motivated — returning Issues1. Distributive conditional type allows export type LoopIterationResult<S, T> = Promise<
LoopResult<S, T> | (S extends undefined ? undefined : never)
>;TypeScript's conditional types distribute over unions, so when
This means To be precise at the type level, this could use a non-distributive form: export type LoopIterationResult<S, T> = Promise<
LoopResult<S, T> | ([S] extends [undefined] ? undefined : never)
>;Wrapping in a tuple 2. Missing negative test case for the runtime guard The PR adds a guard that throws when a stateful loop returns if (iterationResult === undefined && state \!== undefined) {
throw new Error(...)
}There's no test that verifies this path. Adding a test confirming this error is thrown for stateful loops (e.g., a loop with 3. Minor: inconsistent type usage in In the run?: (ctx: WorkflowContextInterface) => Promise<LoopResult<undefined, T> | undefined>,While the interface in What looks good
|

Description
Please include a summary of the changes and the related issue. Please also include relevant motivation and context.
Type of change
How Has This Been Tested?
Please describe the tests that you ran to verify your changes.
Checklist: