@@ -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 |
@@ -2742,7 +2784,9 @@ Resources keeping the event loop alive: |
2742 | 2784 | ``` |
2743 | 2785 |
|
2744 | 2786 | If the main thread was executing JavaScript, its stack trace is printed instead. |
2745 | | -Use [`--report-on-process-timeout`][] to also generate a [diagnostic report][]. |
| 2787 | +Use [`--process-timeout-worker-stacks`][] to also print the stack traces of |
| 2788 | +Worker threads, and [`--report-on-process-timeout`][] to also generate a |
| 2789 | +[diagnostic report][]. |
2746 | 2790 |
|
2747 | 2791 | The process exits without emitting the `'beforeExit'` and `'exit'` events, as |
2748 | 2792 | the JavaScript code may be what keeps the process running. Code coverage and |
@@ -4967,6 +5011,7 @@ node --stack-trace-limit=12 -p -e "Error.stackTraceLimit" # prints 12 |
4967 | 5011 | [`--openssl-config`]: #--openssl-configfile |
4968 | 5012 | [`--preserve-symlinks`]: #--preserve-symlinks |
4969 | 5013 | [`--print`]: #-p---print-script |
| 5014 | +[`--process-timeout-worker-stacks`]: #--process-timeout-worker-stacks |
4970 | 5015 | [`--process-timeout`]: #--process-timeoutduration |
4971 | 5016 | [`--redirect-warnings`]: #--redirect-warningsfile |
4972 | 5017 | [`--report-on-process-timeout`]: #--report-on-process-timeout |
@@ -4987,6 +5032,7 @@ node --stack-trace-limit=12 -p -e "Error.stackTraceLimit" # prints 12 |
4987 | 5032 | [`NO_COLOR`]: https://no-color.org |
4988 | 5033 | [`RealFSProvider`]: vfs.md#class-realfsprovider |
4989 | 5034 | [`Web Storage`]: https://developer.mozilla.org/en-US/docs/Web/API/Web_Storage_API |
| 5035 | +[`Worker`]: worker_threads.md#class-worker |
4990 | 5036 | [`YoungGenerationSizeFromSemiSpaceSize`]: https://chromium.googlesource.com/v8/v8.git/+/refs/tags/10.3.129/src/heap/heap.cc#328 |
4991 | 5037 | [`ZipProvider`]: vfs.md#class-zipprovider |
4992 | 5038 | [`child_process.execSync()`]: child_process.md#child_processexecsynccommand-options |
|