From 521d9df878aeb19015973b109829b43acf34f5d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gianfranc=C3=B8=20Null?= <899175+gianpaj@users.noreply.github.com> Date: Tue, 15 Feb 2022 16:14:43 +0000 Subject: [PATCH] cannot sleep `1 month` - it's 30d (#902) * cannot sleep `1 month` - it's 30d https://github.com/vercel/ms/issues/57 * Update 2022-01-24-workflows-part-I.md * Update workflows.md Co-authored-by: swyx --- blog/2022-01-24-workflows-part-I.md | 4 ++-- docs/typescript/workflows.md | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/blog/2022-01-24-workflows-part-I.md b/blog/2022-01-24-workflows-part-I.md index 908cb4863b..49c0db0f89 100644 --- a/blog/2022-01-24-workflows-part-I.md +++ b/blog/2022-01-24-workflows-part-I.md @@ -97,7 +97,7 @@ function SendReminderEmail(event, context) : Message { return { message: { user: event.user, iter: event.iter + 1}, - after: "1month" + after: "30 days" } } @@ -132,7 +132,7 @@ async function SendReminderEmail(user: string) { // Thanks to Temporal's retry policy, we already // tried twice, better luck next month 🍀 } - await sleep("1 month"); + await sleep("30 days"); } } ``` diff --git a/docs/typescript/workflows.md b/docs/typescript/workflows.md index 8ece65783a..1d85032174 100644 --- a/docs/typescript/workflows.md +++ b/docs/typescript/workflows.md @@ -518,6 +518,10 @@ await sleep(30 * 24 * 60 * 60 * 1000); // numerical API await sleep('30 days').catch(() => { // clean up code if workflow is canceled during sleep }); + +// NOT VALID +await sleep('1 month'); // ms package doesnt support "months" https://github.com/vercel/ms/issues/57 +// use date-fns and sleepUntil instead, see below ``` With this primitive, you can build other abstractions. For example, a `sleepUntil` function that converts absolute time to relative time with `date-fns`: