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
Copy file name to clipboardExpand all lines: docs/troubleshooting.mdx
+32Lines changed: 32 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -181,6 +181,38 @@ View the [rate limits](/limits) page for more information.
181
181
182
182
This can happen in different situations, for example when using plain strings as idempotency keys. Support for `Crypto` without a special flag was added in Node `v19.0.0`. You will have to upgrade Node - we recommend even-numbered major releases, e.g. `v20` or `v22`. Alternatively, you can switch from plain strings to the `idempotencyKeys.create` SDK function. [Read the guide](/idempotency).
183
183
184
+
### Task run stalled executing
185
+
186
+
If you see a `TASK_RUN_STALLED_EXECUTING` error it means that we didn't receive a heartbeat from your task before the stall timeout. We automatically heartbeat runs every 30 seconds, and the heartbeat timeout is 10 minutes.
187
+
188
+
<Note>
189
+
190
+
If this was a dev run, then most likely the `trigger.dev dev` CLI was stopped, and it wasn't an issue with your code.
191
+
192
+
</Note>
193
+
194
+
These errors can happen when code inside your task is blocking the event loop for too long. The most likely cause would be an accidental infinite loop. It could also be a CPU-heavy operation that's blocking the event loop, like nested loops with very large arrays. We recommend reading the [Don't Block the Event Loop](https://nodejs.org/en/learn/asynchronous-work/dont-block-the-event-loop) guide from Node.js for common patterns that can cause this.
195
+
196
+
If you are doing a continuous CPU-heavy task, then we recommend you try using our `heartbeats.yield` function to automatically yield to the event loop periodically:
197
+
198
+
```ts
199
+
import { heartbeats } from"@trigger.dev/sdk";
200
+
201
+
// code inside your task
202
+
for (const row ofbigDataset) {
203
+
awaitheartbeats.yield(); // safe to call every iteration, we will only actually yield when we need to
204
+
process(row); // this is a synchronous operation
205
+
}
206
+
```
207
+
208
+
<Note>
209
+
210
+
You could also offload the CPU-heavy work to a Node.js worker thread, but this is more complex to setup currently. We are planning on adding support for this in the future.
211
+
212
+
</Note>
213
+
214
+
If the above doesn't work, then we recommend you try increasing the machine size of your task. See our [machines guide](/machines) for more information.
? `Run timed out after ${timeoutDuration} due to missing heartbeats (sent every 30s). Check if your \`trigger.dev dev\` CLI is still running, or if CPU-heavy work is blocking the main thread.`
1265
+
: `Run timed out after ${timeoutDuration} due to missing heartbeats (sent every 30s). This typically happens when CPU-heavy work blocks the main thread.`;
1266
+
1269
1267
awaitthis.runAttemptSystem.attemptFailed({
1270
1268
runId,
1271
1269
snapshotId: latestSnapshot.id,
@@ -1278,13 +1276,15 @@ export class RunEngine {
1278
1276
latestSnapshot.executionStatus==="EXECUTING"
1279
1277
? "TASK_RUN_STALLED_EXECUTING"
1280
1278
: "TASK_RUN_STALLED_EXECUTING_WITH_WAITPOINTS",
1281
-
message: `Run stalled while executing. This can happen when the run becomes unresponsive, for example because the CPU is overloaded.`,
0 commit comments