@@ -2716,6 +2716,48 @@ changes: |
2716 | 2716 |
|
2717 | 2717 | Identical to `-e` but prints the result. |
2718 | 2718 |
|
| 2719 | +### `--process-timeout-worker-stacks` |
| 2720 | + |
| 2721 | +<!-- YAML |
| 2722 | +added: REPLACEME |
| 2723 | +--> |
| 2724 | + |
| 2725 | +> Stability: 1.1 - Active development |
| 2726 | +
|
| 2727 | +When [`--process-timeout`][] expires, also prints what each [`Worker`][] thread, |
| 2728 | +including Workers created by other Workers, was doing and which resources were |
| 2729 | +keeping its event loop alive to stderr, after the summary for the main thread: |
| 2730 | + |
| 2731 | +```console |
| 2732 | +$ node --process-timeout=5s --process-timeout-worker-stacks app.js |
| 2733 | +(node:25418) Process timed out after 5s (--process-timeout). Exiting with code 124. |
| 2734 | +Main thread was not executing JavaScript. |
| 2735 | +Resources keeping the event loop alive: |
| 2736 | + Worker (thread 2, name 'WorkerThread') |
| 2737 | + Worker (thread 1, name 'compute') |
| 2738 | +Worker thread 1 (name 'compute') was executing JavaScript: |
| 2739 | + at spin (/home/user/compute.js:3:3) |
| 2740 | + at /home/user/compute.js:6:1 |
| 2741 | + at node:internal/modules/cjs/loader:1989:14 |
| 2742 | + at node:internal/modules/cjs/loader:2129:10 |
| 2743 | + at node:internal/modules/cjs/loader:1711:32 |
| 2744 | + at node:internal/modules/cjs/loader:1501:12 |
| 2745 | + at wrapModuleLoad (node:internal/modules/cjs/loader:261:19) |
| 2746 | + at executeUserEntryPoint (node:internal/modules/run_main:166:5) |
| 2747 | + at node:internal/main/worker_thread:247:26 |
| 2748 | + at [nodejs.internal.kHybridDispatch] (node:internal/event_target:876:20) |
| 2749 | +No resources keeping its event loop alive were found. |
| 2750 | +Worker thread 2 (name 'WorkerThread') was not executing JavaScript. |
| 2751 | +Resources keeping its event loop alive: |
| 2752 | + Timeout (next due in 28ms) |
| 2753 | +``` |
| 2754 | + |
| 2755 | +Worker threads that do not respond within two seconds, for example because |
| 2756 | +they are blocked in a synchronous operation such as |
| 2757 | +[`child_process.execSync()`][], are listed without a stack trace or |
| 2758 | +resources. Requires |
| 2759 | +[`--process-timeout`][]. |
| 2760 | + |
2719 | 2761 | ### `--process-timeout=duration` |
2720 | 2762 |
|
2721 | 2763 | <!-- YAML |
@@ -2746,7 +2788,9 @@ Resources keeping the event loop alive: |
2746 | 2788 | ``` |
2747 | 2789 |
|
2748 | 2790 | If the main thread was executing JavaScript, its stack trace is printed instead. |
2749 | | -Use [`--report-on-process-timeout`][] to also generate a [diagnostic report][]. |
| 2791 | +Use [`--process-timeout-worker-stacks`][] to also print the stack traces of |
| 2792 | +Worker threads, and [`--report-on-process-timeout`][] to also generate a |
| 2793 | +[diagnostic report][]. |
2750 | 2794 |
|
2751 | 2795 | The process exits without emitting the `'beforeExit'` and `'exit'` events, as |
2752 | 2796 | the JavaScript code may be what keeps the process running. Code coverage and |
@@ -4975,6 +5019,7 @@ node --stack-trace-limit=12 -p -e "Error.stackTraceLimit" # prints 12 |
4975 | 5019 | [`--openssl-config`]: #--openssl-configfile |
4976 | 5020 | [`--preserve-symlinks`]: #--preserve-symlinks |
4977 | 5021 | [`--print`]: #-p---print-script |
| 5022 | +[`--process-timeout-worker-stacks`]: #--process-timeout-worker-stacks |
4978 | 5023 | [`--process-timeout`]: #--process-timeoutduration |
4979 | 5024 | [`--redirect-warnings`]: #--redirect-warningsfile |
4980 | 5025 | [`--report-on-process-timeout`]: #--report-on-process-timeout |
@@ -4995,6 +5040,7 @@ node --stack-trace-limit=12 -p -e "Error.stackTraceLimit" # prints 12 |
4995 | 5040 | [`NO_COLOR`]: https://no-color.org |
4996 | 5041 | [`RealFSProvider`]: vfs.md#class-realfsprovider |
4997 | 5042 | [`Web Storage`]: https://developer.mozilla.org/en-US/docs/Web/API/Web_Storage_API |
| 5043 | +[`Worker`]: worker_threads.md#class-worker |
4998 | 5044 | [`YoungGenerationSizeFromSemiSpaceSize`]: https://chromium.googlesource.com/v8/v8.git/+/refs/tags/10.3.129/src/heap/heap.cc#328 |
4999 | 5045 | [`ZipProvider`]: vfs.md#class-zipprovider |
5000 | 5046 | [`child_process.execSync()`]: child_process.md#child_processexecsynccommand-options |
|