Skip to content

Commit df4f600

Browse files
authored
Update "dynamic"/"deterministic" usage in rules-of-workflows.mdx (#18461)
Dynamic is fine. Non-deterministic is not. Clarifying the latter.
1 parent 13f91c2 commit df4f600

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/content/docs/workflows/build/rules-of-workflows.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -243,15 +243,15 @@ export class MyWorkflow extends WorkflowEntrypoint {
243243

244244
### Name steps deterministically
245245

246-
Steps should be named deterministically (even if dynamic). This ensures that their state is cached, and prevents the step from being rerun unnecessarily. Step names act as the "cache key" in your Workflow.
246+
Steps should be named deterministically (ie, not using the current date/time, randomness, etc). This ensures that their state is cached, and prevents the step from being rerun unnecessarily. Step names act as the "cache key" in your Workflow.
247247

248248
<TypeScriptExample filename="index.ts">
249249
```ts
250250
export class MyWorkflow extends WorkflowEntrypoint {
251251
async run(event: WorkflowEvent<Params>, step: WorkflowStep) {
252-
// 🔴 Bad: Dynamically naming the step prevents it from being cached
252+
// 🔴 Bad: Naming the step non-deterministically prevents it from being cached
253253
// This will cause the step to be re-run if subsequent steps fail.
254-
await step.do(`step #1 running at: ${Date.now}`, async () => {
254+
await step.do(`step #1 running at: ${Date.now()}`, async () => {
255255
let userData = await env.KV.get(event.user)
256256
event.data = userData
257257
})

0 commit comments

Comments
 (0)