[types] add restart-from-step support to WorkflowInstance.restart()#6625
[types] add restart-from-step support to WorkflowInstance.restart()#6625
Conversation
There was a problem hiding this comment.
I'm Bonk, and I've done a quick review of your PR.
This PR adds an optional from parameter to WorkflowInstance.restart() so users can restart from a specific step.
Issues found (ranked by severity):
-
[HIGH]
types/defines/workflows.d.tsnot updated — the user-facing type definitions published as@cloudflare/workers-typesstill show the oldrestart(): Promise<void>signature (line 117). Users of@cloudflare/workers-typeswon't seeWorkflowInstanceRestartOptionsor the updatedrestart(options?)signature, and will get a compile error if they try to pass options.Please add the
WorkflowInstanceRestartOptionsinterface totypes/defines/workflows.d.ts(before theWorkflowInstanceclass) and update therestart()signature to match. Then runjust generate-typesand commit the updatedgenerated-snapshot/files. -
[MEDIUM] No test coverage for the new
restart({ from })path — the existing test (src/cloudflare/internal/test/workflows/workflows-api-test.js) doesn't exerciserestart()at all. The mock (workflows-mock.js) also lacks a/restarthandler. See inline comment for details.
This review was written by a bot. It may contain mistakes — please verify any suggestions before applying.
| async restart(options?: WorkflowInstanceRestartOptions): Promise<void> { | ||
| await callFetcher(this.fetcher, '/restart', { | ||
| id: this.id, | ||
| step: options?.from, |
There was a problem hiding this comment.
[MEDIUM] No test coverage for the new restart-from-step feature. The existing test file (src/cloudflare/internal/test/workflows/workflows-api-test.js) doesn't exercise restart() at all, and the mock (workflows-mock.js) has no /restart handler.
Please consider adding tests that:
- call
restart()with no arguments (existing behavior) - call
restart({ from: { name: 'stepName' } })and verify the mock receives{ id, step: { name: 'stepName' } } - call
restart({ from: { name: 'stepName', count: 2, type: 'do' } })to cover the full shape
|
Review posted successfully on PR #6625. Here's a summary of the findings:
|
Extends WorkflowInstance.restart() to accept an optional from parameter, allowing users to restart a workflow instance from a specific step instead of from the beginning.
Supersedes #6591