This repository contains a reproduction case for an issue where terminating a workflow and immediately creating a new one causes an error.
in all variants, we expect the workflow to be terminated successfully and a new workflow to be created immediately after, returning a new workflow ID.
currently, we are seeing internal error when attempting to create the new workflow immediately after termination.
In this variant, a single Durable Object instance handles both the termination of the old workflow and the creation of the new one.
Request: GET /variant1
Response:
{
"variant": 1,
"initialWorkflowId": "17c25582-5903-4708-9fb3-6bd3817456dc",
"result": {
"log": [
"Attempting to terminate workflow 17c25582-5903-4708-9fb3-6bd3817456dc",
"Successfully terminated workflow 17c25582-5903-4708-9fb3-6bd3817456dc",
"Attempting to create new workflow immediately",
"Error occurred: internal error"
],
"error": "internal error"
}
}In this variant, one Durable Object instance terminates the workflow, and a separate Durable Object instance attempts to create a new workflow immediately after.
Request: GET /variant2
Response:
{
"variant": 2,
"initialWorkflowId": "f20c6c6b-280d-4e3c-938c-7863fc26e439",
"log": [
"[V2_A] Terminating workflow f20c6c6b-280d-4e3c-938c-7863fc26e439",
"[V2_A] Terminated workflow",
"[V2_B] Creating new workflow",
"Error: Failed to create workflow: internal error"
],
"error": "Failed to create workflow: internal error"
}In this variant, a Durable Object terminates the workflow, but the creation of the new workflow happens directly in the Worker's fetch handler.
Request: GET /variant3
Response (This is passing :checkmark):
{
"variant": 3,
"initialWorkflowId": "52c7401e-6113-47ff-83dd-d562d55f0d61",
"newWorkflowId": "d86ab7e6-d486-4506-bb6e-b90bec6ed5f5",
"log": [
"[DO] Terminating workflow 52c7401e-6113-47ff-83dd-d562d55f0d61",
"[DO] Terminated workflow",
"[Fetch] Creating new workflow",
"[Fetch] Created new workflow d86ab7e6-d486-4506-bb6e-b90bec6ed5f5"
]
}