Skip to content

[types] add restart-from-step support to WorkflowInstance.restart()#6625

Open
tewaro wants to merge 3 commits intomainfrom
vaish/restart-from-step
Open

[types] add restart-from-step support to WorkflowInstance.restart()#6625
tewaro wants to merge 3 commits intomainfrom
vaish/restart-from-step

Conversation

@tewaro
Copy link
Copy Markdown
Contributor

@tewaro tewaro commented Apr 21, 2026

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

await instance.restart({ from: { name: 'aggregate' } });
await instance.restart({ from: { name: 'process', count: 3 } });
await instance.restart({ from: { name: 'checkpoint', type: 'do' } });

@tewaro tewaro requested review from a team as code owners April 21, 2026 06:18
Copy link
Copy Markdown
Contributor

@ask-bonk ask-bonk Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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):

  1. [HIGH] types/defines/workflows.d.ts not updated — the user-facing type definitions published as @cloudflare/workers-types still show the old restart(): Promise<void> signature (line 117). Users of @cloudflare/workers-types won't see WorkflowInstanceRestartOptions or the updated restart(options?) signature, and will get a compile error if they try to pass options.

    Please add the WorkflowInstanceRestartOptions interface to types/defines/workflows.d.ts (before the WorkflowInstance class) and update the restart() signature to match. Then run just generate-types and commit the updated generated-snapshot/ files.

  2. [MEDIUM] No test coverage for the new restart({ from }) path — the existing test (src/cloudflare/internal/test/workflows/workflows-api-test.js) doesn't exercise restart() at all. The mock (workflows-mock.js) also lacks a /restart handler. 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,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[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

@ask-bonk
Copy link
Copy Markdown
Contributor

ask-bonk Bot commented Apr 21, 2026

Review posted successfully on PR #6625. Here's a summary of the findings:

  1. [HIGH] Missing types/defines/workflows.d.ts update — The user-facing type definitions published as @cloudflare/workers-types still have the old restart(): Promise<void> signature. The new WorkflowInstanceRestartOptions interface and updated signature need to be added there, followed by just generate-types to update the snapshots.

  2. [MEDIUM] No test coverage — The existing workflow tests don't exercise restart() at all (neither the old no-arg path nor the new restart({ from }) path), and the mock lacks a /restart handler.

github run

@tewaro tewaro enabled auto-merge April 21, 2026 06:23
@tewaro tewaro disabled auto-merge April 21, 2026 06:34
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.

4 participants