GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — src: expand --process-timeout output to include workers · nodejs/node@720e0c2

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • doc
    • api
      • cli.md
    • node.1
  • src
    • node_options.cc
    • node_options.h
    • node_watchdog.cc
  • test/parallel
    • test-process-timeout-options.js
    • test-process-timeout-worker-stacks.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎doc/api/cli.md‎

Copy file name to clipboardExpand all lines: doc/api/cli.md
+47-1Lines changed: 47 additions & 1 deletion
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -2716,6 +2716,48 @@ changes:
27162716

27172717
Identical to `-e` but prints the result.
27182718

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+
27192761
### `--process-timeout=duration`
27202762

27212763
<!-- YAML
@@ -2742,7 +2784,9 @@ Resources keeping the event loop alive:
27422784
```
27432785

27442786
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][].
27462790

27472791
The process exits without emitting the `'beforeExit'` and `'exit'` events, as
27482792
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
49675011
[`--openssl-config`]: #--openssl-configfile
49685012
[`--preserve-symlinks`]: #--preserve-symlinks
49695013
[`--print`]: #-p---print-script
5014+
[`--process-timeout-worker-stacks`]: #--process-timeout-worker-stacks
49705015
[`--process-timeout`]: #--process-timeoutduration
49715016
[`--redirect-warnings`]: #--redirect-warningsfile
49725017
[`--report-on-process-timeout`]: #--report-on-process-timeout
@@ -4987,6 +5032,7 @@ node --stack-trace-limit=12 -p -e "Error.stackTraceLimit" # prints 12
49875032
[`NO_COLOR`]: https://no-color.org
49885033
[`RealFSProvider`]: vfs.md#class-realfsprovider
49895034
[`Web Storage`]: https://developer.mozilla.org/en-US/docs/Web/API/Web_Storage_API
5035+
[`Worker`]: worker_threads.md#class-worker
49905036
[`YoungGenerationSizeFromSemiSpaceSize`]: https://chromium.googlesource.com/v8/v8.git/+/refs/tags/10.3.129/src/heap/heap.cc#328
49915037
[`ZipProvider`]: vfs.md#class-zipprovider
49925038
[`child_process.execSync()`]: child_process.md#child_processexecsynccommand-options
Collapse file

‎doc/node.1‎

Copy file name to clipboardExpand all lines: doc/node.1
+36-1Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1415,6 +1415,39 @@ See \fB--preserve-symlinks\fR for more information.
14151415
.It Fl p , Fl -print Ar "script"
14161416
Identical to \fB-e\fR but prints the result.
14171417
.
1418+
.It Fl -process-timeout-worker-stacks
1419+
When \fB--process-timeout\fR expires, also prints what each \fBWorker\fR thread,
1420+
including Workers created by other Workers, was doing and which resources were
1421+
keeping its event loop alive to stderr, after the summary for the main thread:
1422+
.Bd -literal
1423+
$ node --process-timeout=5s --process-timeout-worker-stacks app.js
1424+
(node:25418) Process timed out after 5s (--process-timeout). Exiting with code 124.
1425+
Main thread was not executing JavaScript.
1426+
Resources keeping the event loop alive:
1427+
Worker (thread 2, name 'WorkerThread')
1428+
Worker (thread 1, name 'compute')
1429+
Worker thread 1 (name 'compute') was executing JavaScript:
1430+
at spin (/home/user/compute.js:3:3)
1431+
at /home/user/compute.js:6:1
1432+
at node:internal/modules/cjs/loader:1989:14
1433+
at node:internal/modules/cjs/loader:2129:10
1434+
at node:internal/modules/cjs/loader:1711:32
1435+
at node:internal/modules/cjs/loader:1501:12
1436+
at wrapModuleLoad (node:internal/modules/cjs/loader:261:19)
1437+
at executeUserEntryPoint (node:internal/modules/run_main:166:5)
1438+
at node:internal/main/worker_thread:247:26
1439+
at [nodejs.internal.kHybridDispatch] (node:internal/event_target:876:20)
1440+
No resources keeping its event loop alive were found.
1441+
Worker thread 2 (name 'WorkerThread') was not executing JavaScript.
1442+
Resources keeping its event loop alive:
1443+
Timeout (next due in 28ms)
1444+
.Ed
1445+
Worker threads that do not respond within two seconds, for example because
1446+
they are blocked in a synchronous operation such as
1447+
\fBchild_process.execSync()\fR, are listed without a stack trace or
1448+
resources. Requires
1449+
\fB--process-timeout\fR.
1450+
.
14181451
.It Fl -process-timeout Ns = Ns Ar duration
14191452
Exits the process with code \fB124\fR if it is still running after \fBduration\fR,
14201453
measured from the start of the process. \fBduration\fR is a positive integer
@@ -1431,7 +1464,9 @@ Resources keeping the event loop alive:
14311464
Timeout x2 (next due in 2931ms)
14321465
.Ed
14331466
If the main thread was executing JavaScript, its stack trace is printed instead.
1434-
Use \fB--report-on-process-timeout\fR to also generate a diagnostic report.
1467+
Use \fB--process-timeout-worker-stacks\fR to also print the stack traces of
1468+
Worker threads, and \fB--report-on-process-timeout\fR to also generate a
1469+
diagnostic report.
14351470
The process exits without emitting the \fB'beforeExit'\fR and \fB'exit'\fR events, as
14361471
the JavaScript code may be what keeps the process running. Code coverage and
14371472
profiles, such as those enabled with \fBNODE_V8_COVERAGE=dir\fR or
Collapse file

‎src/node_options.cc‎

Copy file name to clipboardExpand all lines: src/node_options.cc
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,10 @@ void PerProcessOptions::CheckProcessTimeoutOptions(
196196
errors->push_back(
197197
"--report-on-process-timeout must be used with --process-timeout");
198198
}
199+
if (process_timeout_worker_stacks) {
200+
errors->push_back("--process-timeout-worker-stacks must be used with "
201+
"--process-timeout");
202+
}
199203
return;
200204
}
201205

@@ -1823,6 +1827,10 @@ PerProcessOptionsParser::PerProcessOptionsParser(
18231827
"print why the process is still running and exit with code 124 "
18241828
"if it has not exited after the given duration (e.g. 30s)",
18251829
&PerProcessOptions::process_timeout);
1830+
AddOption("--process-timeout-worker-stacks",
1831+
"also print the JavaScript stacks of Worker threads when "
1832+
"--process-timeout expires",
1833+
BOOL_FIELD(process_timeout_worker_stacks));
18261834

18271835
Insert(iop, &PerProcessOptions::get_per_isolate_options);
18281836

Collapse file

‎src/node_options.h‎

Copy file name to clipboardExpand all lines: src/node_options.h
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,7 @@ class PerProcessOptions : public Options {
456456
DEFINE_BOOL_FIELD(disable_wasm_trap_handler) = false;
457457
DEFINE_BOOL_FIELD(report_on_fatalerror) = false;
458458
DEFINE_BOOL_FIELD(report_on_process_timeout) = false;
459+
DEFINE_BOOL_FIELD(process_timeout_worker_stacks) = false;
459460
DEFINE_BOOL_FIELD(report_compact) = false;
460461
DEFINE_BOOL_FIELD(trace_sigint) = false;
461462
// Tracks whether `--run` was passed, since an empty `run` is ambiguous

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.