James M Snell
823d229adc
src: add --process-timeout=N
...
Putting a time limit on a Node.js process is common in many
use cases, but each of the common approaches are generally
flawed.
OS and CI timeouts are inconsistent and blind. Every OS flavor
handles process timeouts in different ways. Stock macOS and
Windows do not ship coreutils `timeout`, etc. None of the options
can explain why the process was still running or what exactly
was interrupted. Using setTimeout only fires when the event loop
is free so it misses busy loops and thread blocks and cannot
see the stack. Diagnostics triggered by signal have the same
problem.
This introduces a `--process-timeout` that should work
consistently across all runtimes. A native watchdog thread
interrupts the main thread, even in the middle of running
code. It prints the JavaScript stack (if any) and resources
keeping the event loop alive (if any), and can optionally
print a full diagnostic report. The process exits with a
distinct code (124). If the main thread is stuck in native
code, the process still exits.
$ node --process-timeout=10s -e "while(true) {}"
(node:483970) Process timed out after 10s (--process-timeout). Exiting with code 124.
Main thread was executing JavaScript:
at [eval]:1:1
at runScriptInThisContext (node:internal/vm:219:10)
at node:internal/process/execution:485:12
at [eval]-wrapper:6:24
at runScriptInContext (node:internal/process/execution:483:60)
at evalFunction (node:internal/process/execution:317:30)
at evalTypeScript (node:internal/process/execution:329:3)
at node:internal/main/eval_string:71:3
No resources keeping the event loop alive were found.
Signed-off-by: James M Snell <jasnell@gmail.com >
Assisted-by: Opencode
PR-URL: https://github.com/nodejs/node/pull/66138
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com >
2026-09-25 20:28:33 +00:00
..
2026-09-22 12:26:39 +01:00
2026-09-13 14:01:18 +02:00
2026-09-16 06:50:14 +00:00
2026-09-16 06:50:14 +00:00
2026-09-12 19:30:04 +00:00
2026-09-12 08:29:12 +00:00
2026-09-12 08:29:12 +00:00
2026-09-12 08:29:12 +00:00
2026-09-12 08:29:12 +00:00
2026-09-12 08:29:12 +00:00
2026-09-12 08:29:12 +00:00
2026-09-12 08:29:12 +00:00
2026-09-25 18:49:35 +00:00
2026-09-12 08:29:12 +00:00
2026-09-12 08:29:12 +00:00
2026-09-12 08:29:12 +00:00
2026-09-12 08:29:12 +00:00
2026-09-12 08:29:12 +00:00
2026-09-21 21:44:24 +00:00
2026-09-12 08:29:12 +00:00
2026-09-12 08:29:12 +00:00
2026-09-12 08:29:12 +00:00
2026-09-12 08:29:12 +00:00
2026-09-12 08:29:12 +00:00
2026-09-12 08:29:12 +00:00
2026-09-12 08:29:12 +00:00
2026-09-12 08:29:12 +00:00
2026-09-25 18:49:36 +00:00
2026-09-12 08:29:12 +00:00
2026-09-12 08:29:12 +00:00
2026-09-13 20:30:46 +00:00
2026-09-25 14:39:01 +00:00
2026-09-25 14:39:01 +00:00
2026-09-25 08:44:58 +00:00
2026-09-19 05:21:30 +00:00
2026-09-10 07:21:44 +00:00
2026-09-15 10:50:17 +02:00
2026-09-12 10:43:37 +00:00
2026-09-18 05:27:26 +00:00
2026-09-12 08:29:12 +00:00
2026-09-11 11:44:15 +00:00
2026-09-13 14:21:48 +00:00
2026-09-18 10:54:52 +00:00
2026-09-25 14:25:32 +00:00
2026-09-12 10:43:27 +00:00
2026-09-13 14:01:15 +02:00
2026-09-13 14:01:15 +02:00
2026-09-13 14:01:15 +02:00
2026-09-25 13:23:24 +00:00
2026-09-17 20:25:55 +00:00
2026-09-20 14:21:44 +00:00
2026-09-10 19:22:57 +00:00
2026-09-25 13:23:26 +00:00
2026-09-23 08:50:56 +00:00
2026-09-23 08:50:56 +00:00
2026-09-23 08:50:56 +00:00
2026-09-20 14:21:45 +00:00
2026-09-23 08:50:56 +00:00
2026-09-23 08:50:56 +00:00
2026-09-20 14:21:48 +00:00
2026-09-10 05:11:24 +00:00
2026-09-25 14:25:32 +00:00
2026-09-12 11:52:10 +00:00
2026-09-09 21:45:48 +00:00
2026-09-20 14:21:48 +00:00
2026-09-23 08:50:56 +00:00
2026-09-20 14:21:48 +00:00
2026-09-25 13:23:03 +00:00
2026-09-17 20:25:55 +00:00
2026-09-14 11:44:13 +00:00
2026-09-20 14:21:42 +00:00
2026-09-20 14:21:47 +00:00
2026-09-25 14:25:32 +00:00
2026-09-10 05:11:24 +00:00
2026-09-12 10:43:27 +00:00
2026-09-12 08:03:45 +00:00
2026-09-15 08:33:52 +00:00
2026-09-13 14:01:17 +02:00
2026-09-16 00:39:35 +00:00
2026-09-16 00:39:35 +00:00
2026-09-16 00:39:35 +00:00
2026-09-16 00:39:35 +00:00
2026-09-16 00:39:35 +00:00
2026-09-16 00:39:35 +00:00
2026-09-16 00:39:35 +00:00
2026-09-16 00:39:35 +00:00
2026-09-16 00:39:35 +00:00
2026-09-16 00:39:35 +00:00
2026-09-16 00:39:35 +00:00
2026-09-16 00:39:35 +00:00
2026-09-16 00:39:35 +00:00
2026-09-16 00:39:35 +00:00
2026-09-16 00:39:35 +00:00
2026-09-16 00:39:35 +00:00
2026-09-16 00:39:35 +00:00
2026-09-16 00:39:35 +00:00
2026-09-16 00:39:35 +00:00
2026-09-16 00:39:35 +00:00
2026-09-16 00:39:35 +00:00
2026-09-16 00:39:35 +00:00
2026-09-16 00:39:35 +00:00
2026-09-16 00:39:35 +00:00
2026-09-16 00:39:35 +00:00
2026-09-16 00:39:35 +00:00
2026-09-16 00:39:35 +00:00
2026-09-16 00:39:35 +00:00
2026-09-16 00:39:35 +00:00
2026-09-16 00:39:35 +00:00
2026-09-16 00:39:35 +00:00
2026-09-16 00:39:35 +00:00
2026-09-16 00:39:35 +00:00
2026-09-16 00:39:35 +00:00
2026-09-16 00:39:35 +00:00
2026-09-16 00:39:35 +00:00
2026-09-16 00:39:35 +00:00
2026-09-25 18:14:48 +02:00
2026-09-13 07:35:14 +00:00
2026-09-25 21:32:36 +02:00
2026-09-12 13:04:57 +02:00
2026-09-20 11:20:30 +00:00
2026-09-18 05:06:20 +00:00
2026-09-12 08:03:54 +00:00
2026-09-15 16:43:38 +00:00
2026-09-11 13:15:27 -04:00
2026-09-11 13:15:27 -04:00
2026-09-11 13:15:27 -04:00
2026-09-11 13:15:27 -04:00
2026-09-11 13:15:27 -04:00
2026-09-25 19:44:48 +00:00
2026-09-18 05:27:15 +00:00
2026-09-25 13:59:31 +00:00
2026-09-24 15:36:00 +00:00
2026-09-22 09:26:05 +00:00
2026-09-11 13:15:27 -04:00
2026-09-15 16:06:11 +00:00
2026-09-21 21:06:44 +00:00
2026-09-14 11:49:43 +02:00
2026-09-13 14:01:14 +02:00
2026-09-13 14:01:14 +02:00
2026-09-12 10:03:06 +02:00
2026-09-16 11:47:09 +00:00
2026-09-13 14:01:14 +02:00
2026-09-13 14:01:14 +02:00
2026-09-13 14:01:14 +02:00
2026-09-13 14:01:14 +02:00
2026-09-13 14:01:14 +02:00
2026-09-13 14:01:14 +02:00
2026-09-13 14:01:14 +02:00
2026-09-13 14:01:14 +02:00
2026-09-12 10:03:06 +02:00
2026-09-13 14:01:14 +02:00
2026-09-13 14:01:14 +02:00
2026-09-12 10:03:06 +02:00
2026-09-12 10:03:06 +02:00
2026-09-14 08:39:17 +00:00
2026-09-14 08:39:17 +00:00
2026-09-13 14:01:14 +02:00
2026-09-13 14:01:14 +02:00
2026-09-13 14:01:14 +02:00
2026-09-13 14:01:14 +02:00
2026-09-13 14:01:14 +02:00
2026-09-12 10:03:06 +02:00
2026-09-12 10:03:06 +02:00
2026-09-13 14:01:14 +02:00
2026-09-13 14:01:14 +02:00
2026-09-25 21:31:04 +02:00
2026-09-15 19:11:35 +00:00
2026-09-15 19:11:35 +00:00
2026-09-13 14:01:14 +02:00
2026-09-13 14:01:14 +02:00
2026-09-13 14:01:14 +02:00
2026-09-12 10:03:06 +02:00
2026-09-13 14:01:14 +02:00
2026-09-13 14:01:14 +02:00
2026-09-13 14:01:14 +02:00
2026-09-13 14:01:14 +02:00
2026-09-13 14:01:14 +02:00
2026-09-13 14:01:14 +02:00
2026-09-13 14:01:14 +02:00
2026-09-13 14:01:14 +02:00
2026-09-13 14:01:14 +02:00
2026-09-13 14:01:14 +02:00
2026-09-13 14:01:14 +02:00
2026-09-12 10:03:06 +02:00
2026-09-14 08:39:17 +00:00
2026-09-13 14:01:14 +02:00
2026-09-25 21:31:04 +02:00
2026-09-12 10:03:06 +02:00
2026-09-13 14:01:14 +02:00
2026-09-13 14:01:14 +02:00
2026-09-18 05:37:29 +00:00
2026-09-24 17:30:20 +00:00
2026-09-09 13:57:36 +00:00
2026-09-12 15:03:46 +00:00
2026-09-12 08:29:12 +00:00
2026-09-24 17:30:20 +00:00
2026-09-18 05:37:18 +00:00
2026-09-18 05:37:18 +00:00
2026-09-12 20:46:35 +00:00
2026-09-12 20:46:35 +00:00
2026-09-22 06:31:22 +00:00
2026-09-25 18:49:35 +00:00
2026-09-25 03:31:53 +00:00
2026-09-25 03:31:52 +00:00
2026-09-25 18:49:35 +00:00
2026-09-25 01:48:26 +00:00
2026-09-12 23:08:44 +00:00
2026-09-14 16:12:38 +00:00
2026-09-14 16:12:38 +00:00
2026-09-25 18:49:35 +00:00
2026-09-25 03:31:51 +00:00
2026-09-12 12:29:45 +00:00
2026-09-25 18:49:35 +00:00
2026-09-25 18:49:35 +00:00
2026-09-25 18:49:35 +00:00
2026-09-19 22:02:10 +00:00
2026-09-19 22:02:10 +00:00
2026-09-19 22:02:08 +00:00
2026-09-19 22:02:10 +00:00
2026-09-20 19:14:10 +00:00
2026-09-16 10:28:00 +00:00
2026-09-24 17:30:20 +00:00
2026-09-25 17:21:04 +00:00
2026-09-16 00:39:35 +00:00
2026-09-25 17:21:04 +00:00
2026-09-25 20:28:33 +00:00
2026-09-25 20:28:33 +00:00
2026-09-25 20:28:33 +00:00
2026-09-25 20:28:33 +00:00
2026-09-25 20:28:33 +00:00
2026-09-17 18:23:21 +02:00
2026-09-18 11:21:12 +02:00
2026-09-12 09:03:03 +00:00
2026-09-12 09:03:03 +00:00
2026-09-12 09:03:03 +00:00
2026-09-15 09:29:34 +00:00
2026-09-15 09:29:34 +00:00
2026-09-15 09:29:34 +00:00
2026-09-15 09:29:34 +00:00
2026-09-19 18:48:22 +00:00
2026-09-24 23:06:18 +00:00
2026-09-24 23:06:18 +00:00
2026-09-25 13:49:42 +00:00
2026-09-13 14:01:16 +02:00
2026-09-14 07:11:10 +00:00
2026-09-22 13:28:01 +00:00
2026-09-13 12:31:04 +00:00
2026-09-20 19:14:12 +00:00
2026-09-18 05:06:10 +00:00
2026-09-18 05:06:10 +00:00
2026-09-22 03:57:34 +00:00
2026-09-25 20:43:00 +02:00
2026-09-18 05:27:02 +00:00
2026-09-24 23:06:21 +00:00
2026-09-22 13:29:06 +00:00
2026-09-22 13:29:06 +00:00
2026-09-24 23:06:21 +00:00
2026-09-24 23:06:21 +00:00
2026-09-22 13:29:06 +00:00
2026-09-22 13:29:06 +00:00
2026-09-24 23:06:23 +00:00
2026-09-24 23:06:21 +00:00
2026-09-22 13:29:06 +00:00
2026-09-24 23:06:21 +00:00
2026-09-24 23:06:21 +00:00
2026-09-24 23:06:21 +00:00
2026-09-24 23:06:23 +00:00
2026-09-24 23:06:21 +00:00
2026-09-24 23:06:21 +00:00
2026-09-17 06:06:16 +00:00
2026-09-24 23:06:16 +00:00
2026-09-24 23:06:23 +00:00
2026-09-24 23:06:18 +00:00
2026-09-24 23:06:23 +00:00
2026-09-24 23:06:23 +00:00
2026-09-24 23:06:21 +00:00
2026-09-24 23:06:21 +00:00
2026-09-18 05:37:18 +00:00
2026-09-12 22:45:11 +00:00
2026-09-12 10:43:48 +00:00
2026-09-20 21:03:24 +00:00
2026-09-10 21:21:29 +00:00
2026-09-11 18:29:26 +00:00
2026-09-11 18:29:26 +00:00
2026-09-11 18:29:26 +00:00
2026-09-17 03:59:38 +00:00
2026-09-25 13:50:11 +00:00
2026-09-12 08:03:35 +00:00
2026-09-11 18:29:26 +00:00
2026-09-19 07:25:44 +00:00
2026-09-14 11:44:13 +00:00
2026-09-12 10:43:27 +00:00
2026-09-24 17:30:20 +00:00
2026-09-24 17:30:20 +00:00
2026-09-24 17:30:20 +00:00
2026-09-24 17:30:20 +00:00
2026-09-24 17:30:20 +00:00
2026-09-24 17:30:20 +00:00
2026-09-24 17:30:20 +00:00
2026-09-24 17:30:20 +00:00
2026-09-24 17:30:20 +00:00
2026-09-12 08:28:59 +00:00
2026-09-15 02:31:44 +00:00
2026-09-25 18:14:48 +02:00
2026-09-25 15:36:32 +00:00
2026-09-15 16:05:54 +00:00
2026-09-15 16:05:54 +00:00
2026-09-15 08:33:52 +00:00
2026-09-15 16:06:32 +00:00
2026-09-15 16:06:32 +00:00
2026-09-16 10:28:00 +00:00
2026-09-23 14:45:25 +00:00
2026-09-23 14:45:25 +00:00
2026-09-16 19:34:12 +00:00
2026-09-15 05:26:45 +00:00
2026-09-12 09:34:36 +00:00
2026-09-25 09:37:00 +00:00
2026-09-23 01:42:24 +00:00
2026-09-23 01:42:24 +00:00
2026-09-25 18:14:48 +02:00
2026-09-23 08:50:56 +00:00
2026-09-25 13:23:08 +00:00
2026-09-25 13:23:26 +00:00
2026-09-25 13:23:04 +00:00
2026-09-25 13:23:06 +00:00
2026-09-25 13:23:09 +00:00
2026-09-25 13:23:15 +00:00
2026-09-25 13:23:22 +00:00
2026-09-10 18:46:24 +00:00
2026-09-23 08:50:56 +00:00
2026-09-25 14:25:32 +00:00
2026-09-23 08:50:56 +00:00
2026-09-23 08:50:56 +00:00
2026-09-25 13:23:15 +00:00
2026-09-25 13:23:16 +00:00
2026-09-23 08:50:56 +00:00
2026-09-25 13:23:26 +00:00
2026-09-25 13:23:11 +00:00
2026-09-25 13:23:26 +00:00
2026-09-25 13:23:23 +00:00
2026-09-23 08:50:56 +00:00
2026-09-25 14:25:32 +00:00
2026-09-23 08:50:56 +00:00
2026-09-25 13:23:26 +00:00
2026-09-25 13:23:26 +00:00
2026-09-25 13:23:26 +00:00
2026-09-25 13:23:03 +00:00
2026-09-25 13:23:07 +00:00
2026-09-25 13:23:21 +00:00
2026-09-25 13:23:11 +00:00
2026-09-25 13:23:26 +00:00
2026-09-25 13:23:14 +00:00
2026-09-25 13:23:22 +00:00
2026-09-25 13:23:26 +00:00
2026-09-23 08:50:56 +00:00
2026-09-25 13:23:27 +00:00
2026-09-25 13:23:15 +00:00
2026-09-25 13:23:12 +00:00
2026-09-25 13:23:15 +00:00
2026-09-25 13:23:26 +00:00
2026-09-25 13:23:07 +00:00
2026-09-25 13:23:07 +00:00
2026-09-23 08:50:56 +00:00
2026-09-25 13:23:17 +00:00
2026-09-25 13:23:13 +00:00
2026-09-25 13:23:19 +00:00
2026-09-25 13:23:23 +00:00
2026-09-25 13:23:26 +00:00
2026-09-25 14:25:32 +00:00
2026-09-25 13:23:15 +00:00
2026-09-25 13:23:10 +00:00
2026-09-25 13:23:09 +00:00
2026-09-23 08:50:56 +00:00
2026-09-25 13:23:18 +00:00
2026-09-25 13:23:15 +00:00
2026-09-25 13:23:26 +00:00
2026-09-12 11:01:37 +00:00
2026-09-12 12:29:58 +00:00
2026-09-25 13:49:56 +00:00
2026-09-21 03:09:28 +00:00
2026-09-11 14:57:09 +00:00
2026-09-25 13:49:29 +00:00
2026-09-11 14:57:07 +00:00