0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-30 15:30:56 +01:00
nodejs/lib/internal
Miroslav Bajtoš a0895ed6c4
inspector: enable async stack traces
Implement a special async_hooks listener that forwards information
about async tasks to V8Inspector asyncTask* API, thus enabling
DevTools feature "async stack traces".

The feature is enabled only on 64bit platforms due to a technical
limitation of V8 Inspector: inspector uses a pointer as a task id,
while async_hooks use 64bit numbers as ids.

To avoid performance penalty of async_hooks when not debugging,
the new listener is enabled only when the process enters a debug mode:

 - When the process is started with `--inspect` or `--inspect-brk`,
   the listener is enabled immediately and async stack traces
   lead all the way to the first tick of the event loop.

 - When the debug mode is enabled via SIGUSR1 or `_debugProcess()`,
   the listener is enabled together with the debugger. As a result,
   only async operations started after the signal was received
   will be correctly observed and reported to V8 Inspector. For example,
   a `setInterval()` called in the first tick of the event will not be
   shown in the async stack trace when the callback is invoked. This
   behaviour is consistent with Chrome DevTools.

Last but not least, this commit fixes handling of InspectorAgent's
internal property `enabled_` to ensure it's set back to `false`
after the debugger is deactivated (typically via `process._debugEnd()`).

Fixes: https://github.com/nodejs/node/issues/11370
PR-URL: https://github.com/nodejs/node/pull/13870
Reviewed-by: Timothy Gu <timothygu99@gmail.com>
Reviewed-by: Anna Henningsen <anna@addaleax.net>
2017-08-17 20:52:39 +08:00
..
cluster lib,src: fix consistent spacing inside braces 2017-07-21 15:13:47 -04:00
http2 http2: Expose Http2ServerRequest/Response 2017-08-16 12:58:59 +03:00
process lib: move deprecationWarned var 2017-08-14 07:42:08 +02:00
streams net: return this from destroy() 2017-06-14 13:15:51 -07:00
test test: add Unicode characters regression test 2017-04-04 11:14:14 -07:00
bootstrap_node.js inspector: enable async stack traces 2017-08-17 20:52:39 +08:00
buffer.js buffer: refactor module.exports, imports 2017-07-24 07:24:53 -07:00
child_process.js child_process: defer error to next tick 2017-08-13 10:23:50 -07:00
encoding.js encoding: rudimentary TextDecoder support w/o ICU 2017-08-05 16:40:41 +08:00
errors.js async_hooks: don't abort unnecessarily 2017-08-14 23:21:01 +02:00
freelist.js lib: update indentation of ternaries 2017-07-17 22:09:46 -07:00
fs.js errors: port internal/fs errors to internal/errors 2017-07-18 23:55:20 -04:00
http.js http2: introducing HTTP/2 2017-08-04 12:55:44 -07:00
inspector_async_hook.js inspector: enable async stack traces 2017-08-17 20:52:39 +08:00
linkedlist.js linkedlist: correct grammar in comments 2017-07-31 08:03:19 +08:00
module.js http2: introducing HTTP/2 2017-08-04 12:55:44 -07:00
net.js net: add symbol to normalized connect() args 2017-05-19 11:22:40 -04:00
os.js os: add CIDR support 2017-08-14 15:43:10 -04:00
process.js doc, lib, test: do not re-require needlessly 2017-07-21 20:40:52 +03:00
querystring.js lib: use Object.create(null) directly 2017-03-24 15:25:49 -07:00
readline.js lib: remove excess indentation 2017-07-07 13:18:19 -07:00
readme.md doc: limit lines to 80 cols in internal README 2017-04-13 15:30:10 -07:00
repl.js repl: fix old history error handling 2017-06-30 19:21:23 +02:00
socket_list.js lib,src: fix consistent spacing inside braces 2017-07-21 15:13:47 -04:00
url.js url: update sort() behavior with no params 2017-08-01 11:58:15 +08:00
util.js lib: tweak use of internal/errors 2017-07-22 18:18:04 -04:00
v8_prof_polyfill.js v8: fix RegExp nits in v8_prof_polyfill.js 2017-06-19 02:21:15 +03:00
v8_prof_processor.js profiler: declare missing printErr 2017-06-12 14:10:35 +02:00

Internal Modules

The modules in lib/internal are intended for internal use in Node.js core only, and are not accessible with require() from user modules. These are subject to change at any time. Reliance on these modules outside of core is not supported in any way.