You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/content/docs/workflows/build/rules-of-workflows.mdx
+74Lines changed: 74 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -205,6 +205,80 @@ export class MyWorkflow extends WorkflowEntrypoint {
205
205
```
206
206
</TypeScriptExample>
207
207
208
+
### Workflow code re-executes after hibernation
209
+
210
+
When a Workflow hibernates and resumes, it's important to understand that **the entire workflow function runs again from the beginning**. However, completed steps return their cached results immediately without re-executing their logic.
211
+
212
+
This means:
213
+
- All code outside of steps is re-executed
214
+
- Variables defined outside steps are re-initialized
215
+
- Non-deterministic values (like `Math.random()` or `Date.now()`) outside steps will produce different results
216
+
- Only values returned from `step.do()` calls are preserved across hibernations
// state.iteration comes from previous step, survives hibernation
274
+
return { iteration: state.iteration+1 };
275
+
});
276
+
}
277
+
}
278
+
}
279
+
```
280
+
</TypeScriptExample>
281
+
208
282
### Do not mutate your incoming events
209
283
210
284
The `event` passed to your Workflow's `run` method is immutable: changes you make to the event are not persisted across steps and/or Workflow restarts.
0 commit comments