ENF News Bot
Automated News Bot
- Joined
- Apr 15, 2022
- Messages
- 2,591
You can now delete one or up to 100 Workflow instances and their stored state via the Workflows API or Wrangler 4.125.0 and later. Deleting an instance frees its stored state and stops its current execution. Storage billing is based on the average daily peak.
Delete one instance by calling
If a Workflow deletes its own instance, execution stops during
Delete multiple instances by calling
The batch result contains
Wrangler accepts positional instance IDs, a file containing a top-level JSON array of strings, or both, up to 100 IDs total. Use
instance-ids.jsonjson
For more information, refer to Delete Workflow instances,
Continue reading...
Delete one instance by calling
delete() on its handle:
Code:
const instance = await env.MY_WORKFLOW.get("instance-abc");
await instance.delete();
If a Workflow deletes its own instance, execution stops during
await instance.delete(). Code after the call does not run.Delete multiple instances by calling
deleteBatch() on the Workflow binding:
Code:
const result = await env.MY_WORKFLOW.deleteBatch([
"instance-abc",
"instance-def",
]);
console.log(result.deleted);
console.log(result.errors);
The batch result contains
{ id } entries for successful deletions and per-instance errors. IDs that do not exist are returned as errors. Duplicate IDs count toward the limit and are deleted once, with the result repeated for each input position.Wrangler accepts positional instance IDs, a file containing a top-level JSON array of strings, or both, up to 100 IDs total. Use
latest to delete the most recently created instance. Use --local against a local wrangler dev session:instance-ids.jsonjson
["instance-abc", "instance-def"]
Code:
npx wrangler workflows instances delete my-workflow <INSTANCE_ID>
npx wrangler workflows instances delete my-workflow <INSTANCE_ID> <INSTANCE_ID>
npx wrangler workflows instances delete my-workflow latest
npx wrangler workflows instances delete my-workflow --filename ./instance-ids.json
npx wrangler workflows instances delete my-workflow <INSTANCE_ID> --local
For more information, refer to Delete Workflow instances,
delete, and deleteBatch.Continue reading...