Skip to content

Commit 521d9df

Browse files
gianpajswyxio
andauthored
cannot sleep 1 month - it's 30d (#902)
* cannot sleep `1 month` - it's 30d vercel/ms#57 * Update 2022-01-24-workflows-part-I.md * Update workflows.md Co-authored-by: swyx <[email protected]>
1 parent 6e14025 commit 521d9df

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

blog/2022-01-24-workflows-part-I.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ function SendReminderEmail(event, context) : Message {
9797

9898
return {
9999
message: { user: event.user, iter: event.iter + 1},
100-
after: "1month"
100+
after: "30 days"
101101
}
102102
}
103103

@@ -132,7 +132,7 @@ async function SendReminderEmail(user: string) {
132132
// Thanks to Temporal's retry policy, we already
133133
// tried twice, better luck next month 🍀
134134
}
135-
await sleep("1 month");
135+
await sleep("30 days");
136136
}
137137
}
138138
```

docs/typescript/workflows.md

+4
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,10 @@ await sleep(30 * 24 * 60 * 60 * 1000); // numerical API
518518
await sleep('30 days').catch(() => {
519519
// clean up code if workflow is canceled during sleep
520520
});
521+
522+
// NOT VALID
523+
await sleep('1 month'); // ms package doesnt support "months" https://github.com/vercel/ms/issues/57
524+
// use date-fns and sleepUntil instead, see below
521525
```
522526

523527
With this primitive, you can build other abstractions. For example, a `sleepUntil` function that converts absolute time to relative time with `date-fns`:

0 commit comments

Comments
 (0)