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
// A long sleep can (and probably will) hibernate the engine which means that the first engine lifetime ends here
@@ -188,11 +188,11 @@ export class MyWorkflow extends WorkflowEntrypoint {
188
188
// multiple engine lifetimes, imageList will be built accordingly
189
189
const imageList:string[] =awaitPromise.all([
190
190
step.do("get first cutest cat from KV", async () => {
191
-
returnawaitenv.KV.get("cutest-http-cat-1");
191
+
returnawaitthis.env.KV.get("cutest-http-cat-1");
192
192
}),
193
193
194
194
step.do("get second cutest cat from KV", async () => {
195
-
returnawaitenv.KV.get("cutest-http-cat-2");
195
+
returnawaitthis.env.KV.get("cutest-http-cat-2");
196
196
}),
197
197
]);
198
198
@@ -221,7 +221,7 @@ It is not recommended to write code with any side effects outside of steps, unle
221
221
222
222
For example, a `console.log()` outside of workflow steps may cause the logs to print twice when the engine restarts.
223
223
224
-
However, logic involving non-serializable resources, like a database connection, should be executed outside of steps. Operations ouside of a `step.do` might be repeated more than once, due to the nature of the Workflows' instance lifecycle.
224
+
However, logic involving non-serializable resources, like a database connection, should be executed outside of steps. Operations outside of a `step.do` might be repeated more than once, due to the nature of the Workflows' instance lifecycle.
225
225
226
226
<TypeScriptExamplefilename="index.ts">
227
227
@@ -230,14 +230,14 @@ export class MyWorkflow extends WorkflowEntrypoint {
// 🔴 Bad: The step isn't await'ed, and any state or errors is swallowed before it returns.
493
-
constissues=step.do(`fetch issues from GitHub`, async () => {
493
+
constbadIssues=step.do(`fetch issues from GitHub`, async () => {
494
494
// The step will return before this call is done
495
495
let issues =awaitgetIssues(event.payload.repoName);
496
496
returnissues;
497
497
});
498
498
499
499
// ✅ Good: The step is correctly await'ed.
500
-
constissues=awaitstep.do(`fetch issues from GitHub`, async () => {
500
+
constgoodIssues=awaitstep.do(`fetch issues from GitHub`, async () => {
501
501
let issues =awaitgetIssues(event.payload.repoName);
502
502
returnissues;
503
503
});
@@ -557,7 +557,7 @@ export class MyWorkflow extends WorkflowEntrypoint {
557
557
558
558
### Batch multiple Workflow invocations
559
559
560
-
When creating multiple Workflow instances, use the [`createBatch`](/workflows/build/workers-api/#createBatch) method to batch the invocations together. This allows you to create multiple Workflow instances in a single request, which will reduce the number of requests made to the Workflows API. However, each individual instance in the batch will still count towards the [creation rate limit](/workflows/reference/limits/).
560
+
When creating multiple Workflow instances, use the [`createBatch`](/workflows/build/workers-api/#createBatch) method to batch the invocations together. This allows you to create multiple Workflow instances in a single request, which will reduce the number of requests made to the Workflows API. However, each individual instance in the batch will still count towards the [creation rate limit](/workflows/reference/limits/). Unlike `create`, `createBatch` is idempotent: if an existing instance with the same ID is still within its [retention limit](/workflows/reference/limits/), it will be skipped and excluded from the returned array.
Copy file name to clipboardExpand all lines: src/content/docs/workflows/build/sleeping-and-retrying.mdx
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -77,14 +77,14 @@ When providing your own `StepConfig`, you can configure:
77
77
For example, to limit a step to 10 retries and have it apply an exponential delay (starting at 10 seconds) between each attempt, you would pass the following configuration as an optional object to `step.do`:
78
78
79
79
```ts
80
-
let someState =step.do("call an API", {
80
+
let someState =awaitstep.do("call an API", {
81
81
retries: {
82
82
limit: 10, // The total number of attempts
83
83
delay: "10 seconds", // Delay between each retry
84
84
backoff: "exponential"// Any of "constant" | "linear" | "exponential";
0 commit comments