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
**Important:** On the Tailor runtime, job triggers are executed synchronously. This means `Promise.all([jobA.trigger(), jobB.trigger()])` will not run jobs in parallel.
117
117
118
+
### Deterministic Execution Requirement
119
+
120
+
Workflow jobs use a **suspend/resume execution model**. When a job calls `.trigger()`, the runtime suspends the current job, executes the triggered job, and then **re-executes the calling job from the beginning** with cached results from previous triggers.
121
+
122
+
This means that **job code must be deterministic** — every re-execution must produce the same sequence of `.trigger()` calls with the same arguments in the same order.
123
+
124
+
Using `.trigger()` inside a loop works correctly, as long as the loop is deterministic:
125
+
126
+
```typescript
127
+
// ✅ OK: deterministic loop — same calls in the same order on every execution
128
+
const regions = ["us", "eu", "ap"];
129
+
for (const region ofregions) {
130
+
const result =awaitfetchData.trigger({ region });
131
+
results.push(result);
132
+
}
133
+
```
134
+
135
+
```typescript
136
+
// ❌ Bad: non-deterministic — argument changes between executions
// ✅ OK: call fetch("https://api.example.com/items").then((r) => r.json()); in separated job
152
+
const items =awaitfetchItemsJob.trigger();
153
+
for (const item ofitems) {
154
+
awaitprocessItem.trigger({ id: item.id });
155
+
}
156
+
```
157
+
158
+
If the runtime detects that a `.trigger()` call at the same position has different arguments than the previous execution, it will throw an **argument hash mismatch error**.
159
+
160
+
**Guidelines:**
161
+
162
+
- Do not use non-deterministic values (random numbers, timestamps, external API responses) as `.trigger()` arguments.
163
+
- Do not use conditions that may change between executions to decide whether to call `.trigger()`.
164
+
- Any data that varies between executions should be fetched **inside the triggered job**, not passed as an argument from the calling job.
165
+
118
166
## Workflow Definition
119
167
120
168
Define a workflow using `createWorkflow` and export it as default:
0 commit comments