Commit graph

197 commits

Author SHA1 Message Date
theanarkh
9ec68afdc5
worker: fix worker name with \0
Some checks failed
Coverage Windows / coverage-windows (push) Waiting to run
Coverage Linux / coverage-linux (push) Failing after 1m29s
Coverage Linux (without intl) / coverage-linux-without-intl (push) Failing after 1m29s
Linters / lint-cpp (push) Successful in 3m46s
Test and upload documentation to artifacts / build-docs (push) Failing after 5m35s
Linters / lint-py (push) Successful in 2m40s
Linters / lint-sh (push) Failing after 1m25s
Linters / lint-addon-docs (push) Successful in 2m20s
Linters / format-cpp (push) Has been skipped
Linters / lint-yaml (push) Successful in 2m13s
Linters / lint-codeowners (push) Failing after 57s
Linters / lint-pr-url (push) Has been skipped
Linters / lint-readme (push) Successful in 1m26s
Notify on Push / Notify on Force Push on `main` (push) Has been skipped
Notify on Push / Notify on Push on `main` that lacks metadata (push) Has been skipped
Scorecard supply-chain security / Scorecard analysis (push) Failing after 53s
Linters / lint-js-and-md (push) Failing after 19m26s
PR-URL: https://github.com/nodejs/node/pull/59214
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
2025-08-13 13:53:24 +00:00
theanarkh
345a550fa1
src: call unmask after install signal handler
PR-URL: https://github.com/nodejs/node/pull/59059
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2025-07-25 18:15:22 +00:00
Shima Ryuhei
b7db89f491
inspector: initial support for Network.loadNetworkResource
Fixes: https://github.com/nodejs/node/issues/57873
PR-URL: https://github.com/nodejs/node/pull/58077
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
2025-07-10 12:34:11 +00:00
Shima Ryuhei
2281a04e5e
inspector: support for worker inspection in chrome devtools
Fixes: https://github.com/nodejs/node/issues/56343
PR-URL: https://github.com/nodejs/node/pull/56759
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2025-05-12 13:25:00 +00:00
Chengzhong Wu
b7beb3334e
inspector: convert event params to protocol without json
Event params object can be converted to inspector protocol directly.
This also enables binary data, like `Network.dataReceived`, to be sent
in the inspector protocol from JavaScript since JSON representation
does not support plain binary data.

PR-URL: https://github.com/nodejs/node/pull/57027
Reviewed-By: Kohei Ueno <kohei.ueno119@gmail.com>
2025-02-24 12:36:23 +00:00
Chengzhong Wu
b18153598b inspector: add Network.Initiator in inspector protocol
Add initiator stack trace in inspector network events, reflecting
the location where the script created the request.

The `http.client.request.created` event is closer to where user code
creates the http request, and correctly reflects which script
initiated the request.

PR-URL: https://github.com/nodejs/node/pull/56805
Refs: https://github.com/nodejs/node/issues/53946
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Kohei Ueno <kohei.ueno119@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
2025-02-08 13:39:19 +00:00
James M Snell
269496e8e1
src: improve error handling in encoding_binding.cc
PR-URL: https://github.com/nodejs/node/pull/56915
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Xuguang Mei <meixuguang@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
2025-02-06 16:12:42 +00:00
RafaelGSS
d7aacbebd6 src: set signal inspector io thread name
PR-URL: https://github.com/nodejs/node/pull/56416
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
2025-02-06 01:36:28 +00:00
Chengzhong Wu
744c2f507b inspector: roll inspector_protocol
Roll the inspector_protocol library to match V8's inspector_protocol
revision.

Update the node inspector to use the new `crdtp` protocol library.

PR-URL: https://github.com/nodejs/node/pull/56649
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
2025-01-26 23:20:09 +00:00
Kohei Ueno
a523c345b1
inspector: add initial support for network inspection
PR-URL: https://github.com/nodejs/node/pull/53593
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Paolo Insogna <paolo@cowtech.it>
2024-07-19 05:00:30 +00:00
Daeyeon Jeong
e1b80a5fb3
src: fix Worker termination when '--inspect-brk' is passed
Signed-off-by: Daeyeon Jeong <daeyeon.dev@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/53724
Fixes: https://github.com/nodejs/node/issues/53648
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Kohei Ueno <kohei.ueno119@gmail.com>
2024-07-06 15:49:50 +00:00
Joyee Cheung
0c1c33a2a3
inspector: fix disable async hooks on Debugger.setAsyncCallStackDepth
This was previously calling the enable function by mistake. As a
result, when profiling using Chrome DevTools, the async hooks won't
be turned off properly after receiving Debugger.setAsyncCallStackDepth
with depth 0.

PR-URL: https://github.com/nodejs/node/pull/53473
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Yagiz Nizipli <yagiz.nizipli@sentry.io>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
2024-06-18 16:02:25 +00:00
Daeyeon Jeong
ac5f8f0516
src: fix Worker termination in inspector.waitForDebugger
Signed-off-by: Daeyeon Jeong <daeyeon.dev@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/52527
Fixes: https://github.com/nodejs/node/issues/52467
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Kohei Ueno <kohei.ueno119@gmail.com>
2024-05-13 05:08:57 +00:00
Shelley Vohr
56b316294d
src: allow preventing debug signal handler start
PR-URL: https://github.com/nodejs/node/pull/46681
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
2024-05-12 12:26:55 +02:00
Kohei Ueno
c0ae3b2373
inspector: introduce the --inspect-wait flag
PR-URL: https://github.com/nodejs/node/pull/52734
Reviewed-By: Daeyeon Jeong <daeyeon.dev@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
2024-05-11 18:48:30 +00:00
mary marchini
0161ad0baf
inspector: add NodeRuntime.waitingForDebugger event
`NodeRuntime.waitingForDebugger` is a new Inspector Protocol event that
will fire when the process being inspected is waiting for the debugger
(for example, when `inspector.waitForDebugger()` is called). This allows
inspecting processes to know when the inspected process is waiting for a
`Runtime.runIfWaitingForDebugger` message to resume execution. It allows
tooling to resume execution of the inspected process as soon as it deems
necessary, without having to guess if the inspected process is waiting
or not, making the workflow more deterministic. With a more
deterministic workflow, it is possible to update Node.js core tests to
avoid race conditions that can cause flakiness. Therefore, tests were
also changed as following:

  * Remove no-op Runtime.runIfWaitingForDebugger from tests that don't
    need it
  * Use NodeRuntime.waitingForDebugger in all tests that need
    Runtime.runIfWaitingForDebugger, to ensure order of operations is
    predictable and correct
  * Simplify test-inspector-multisession-ws

There might be value in adding `NodeWorker.waitingForDebugger` in a
future patch, but as of right now, no Node.js core inspector tests using
worker threads are not failing due to race conditions.

Fixes: https://github.com/nodejs/node/issues/34730
PR-URL: https://github.com/nodejs/node/pull/51560
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
2024-02-23 22:46:29 +00:00
Chengzhong Wu
16a54794df
src: fix backtrace with tail [[noreturn]] abort
A function tail calls [[noreturn]] node::Abort will print an incorrect
call stack because the frame pc was advanced when calling node::Abort
to an invalid op, which may vary on different platforms.

Dumps the backtrace in the ABORT macro instead to avoid calling
backtrace in a tail [[noreturn]] call. Removes the [[noreturn]]
attribute if a function calls backtrace and may be called as a tail
statement.

[[noreturn]] attribute of public functions like `napi_fatal_error` and
`node::OnFatalError` can not be removed as compilers may complain
about no return values after the removal.

PR-URL: https://github.com/nodejs/node/pull/50849
Refs: https://github.com/nodejs/node/issues/50761
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
2023-12-03 16:42:57 +00:00
Daniel Lemire
2990390359
inspector: simplify dispatchProtocolMessage
PR-URL: https://github.com/nodejs/node/pull/49780
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
2023-09-30 01:58:09 +00:00
Jason
f426cc0c3f
src: modernize use-equals-default
PR-URL: https://github.com/nodejs/node/pull/48735
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
2023-08-11 17:58:04 +00:00
RafaelGSS
34d92ed88c src,permission: restrict inspector when pm enabled
PR-URL: https://github.com/nodejs-private/node-private/pull/410
Refs: https://hackerone.com/bugs?subject=nodejs&report_id=1962701
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
CVE-ID: CVE-2023-30587
2023-06-20 17:30:27 -03:00
Chengzhong Wu
6700aac615
src: mark fatal error functions as noreturn
OnFatalError and OOMErrorHandler will not return control flow to the
calling function.

node::FatalError is an alias of node::OnFatalError. Replace all the
callsites with node::OnFatalError instead.

PR-URL: https://github.com/nodejs/node/pull/47695
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
2023-04-27 08:57:52 +00:00
Joyee Cheung
434bdde974
inspector: log response and requests in the inspector for debugging
Logs the raw messages from the inspector when NODE_DEBUG_NATIVE
is set to inspector_server to facilitate debugging.

PR-URL: https://github.com/nodejs/node/pull/46941
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
2023-03-22 09:28:02 +00:00
Debadree Chatterjee
2d9bf91fe1
worker: add support for worker name in inspector and trace_events
Fixes: https://github.com/nodejs/node/issues/41589
PR-URL: https://github.com/nodejs/node/pull/46832
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
2023-03-06 16:34:09 +00:00
Yagiz Nizipli
c4581abff6 url: replace url-parser with ada
PR-URL: https://github.com/nodejs/node/pull/46410
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
2023-02-06 19:21:39 +00:00
Michaël Zasso
96026646d7
src: avoid unused variables and functions
PR-URL: https://github.com/nodejs/node/pull/45542
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
2022-11-22 12:50:54 +00:00
Moshe Atlow
54eb543933
src: fix test runner coverage
PR-URL: https://github.com/nodejs/node/pull/45055
Fixes: https://github.com/nodejs/node/issues/45013
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
2022-10-20 18:21:20 +00:00
Michaël Zasso
c10988db44
src: use non-deprecated V8 inspector API
PR-URL: https://github.com/nodejs/node/pull/44741
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2022-10-11 07:27:22 +02:00
Moshe Atlow
beb0520af7 cli: add --watch
PR-URL: https://github.com/nodejs/node/pull/44366
Fixes: https://github.com/nodejs/node/issues/40429
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
2022-09-05 12:25:09 +03:00
Antoine du Hamel
1e761654d3
doc: consolidate use of multiple-byte units
Refs: https://en.wikipedia.org/wiki/Byte#Multiple-byte_units

PR-URL: https://github.com/nodejs/node/pull/42587
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Paolo Insogna <paolo@cowtech.it>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Mestery <mestery@protonmail.com>
2022-04-20 00:46:37 +02:00
Shelley Vohr
0367b5c35e
src: allow preventing InitializeInspector in env
PR-URL: https://github.com/nodejs/node/pull/35025
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2022-02-23 23:32:30 +00:00
Darshan Sen
2d368da19f
src: prevent extra copies of TimerWrap::TimerCb
I noticed that we were taking `TimerCb` as a `const&` and then copying
that into the member. This is completely fine when the constructor is
called with an lvalue. However, when called with an rvalue, we can allow
the `std::function` to be moved into the member instead of falling back
to a copy, so I changed the constructors to take in universal
references. Also, `std::function` constructors can take in multiple
arguments, so I further modified the constructors to use variadic
templates.

Signed-off-by: Darshan Sen <darshan.sen@postman.com>

PR-URL: https://github.com/nodejs/node/pull/40665
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
2021-11-12 21:47:42 +00:00
Shelley Vohr
f8836b208c
src: fix -Wunreachable-code-return error
PR-URL: https://github.com/nodejs/node/pull/40034
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2021-09-11 09:55:48 +02:00
Joyee Cheung
1544e69b93
inspector: move inspector async hooks to environment
Since async hooks are per-environment and putting them in
the environment allows us to serialize them for the
snapshot automatically.

PR-URL: https://github.com/nodejs/node/pull/39112
Refs: https://github.com/nodejs/node/pull/38905
Refs: https://github.com/nodejs/node/issues/35711
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2021-07-02 22:13:25 +08:00
Darshan Sen
fa7cdd6fc9
src: use SPrintF in ProcessEmitWarning
PR-URL: https://github.com/nodejs/node/pull/38758
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2021-05-25 07:16:42 -07:00
Yash Ladha
0f5a76f858
inspector: remove redundant method for connection check
PR-URL: https://github.com/nodejs/node/pull/37986
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2021-04-30 13:29:47 -07:00
Michaël Zasso
001dc16cf1
src: use non-deprecated V8 module and script APIs
PR-URL: https://github.com/nodejs/node/pull/37330
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2021-02-25 00:16:41 +01:00
Michaël Zasso
d1f1fcfe0c
src: avoid implicit type conversions (take 2)
This fixes more C4244 MSVC warnings in the code base.

Refs: https://github.com/nodejs/node/pull/37149

PR-URL: https://github.com/nodejs/node/pull/37334
Reviewed-By: James M Snell <jasnell@gmail.com>
2021-02-20 10:50:28 +01:00
Daijiro Wachi
e40ed2856f src: integrate URL::href() and use in inspector
PR-URL: https://github.com/nodejs/node/pull/35912
Refs: https://github.com/nodejs/node/issues/22610
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2020-11-22 00:02:32 +09:00
Daijiro Wachi
bb62f4ad9e url: file URL path normalization
Refs: https://github.com/whatwg/url/pull/544
Refs: https://github.com/web-platform-tests/wpt/pull/25716

PR-URL: https://github.com/nodejs/node/pull/35477
Fixes: https://github.com/nodejs/node/issues/35429
Reviewed-By: Guy Bedford <guybedford@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: Bradley Farias <bradley.meck@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
2020-10-12 15:06:55 +09:00
Tobias Nießen
1be7bbdc3b src: prefer C++ empty() in boolean expressions
PR-URL: https://github.com/nodejs/node/pull/34432
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
2020-08-11 13:22:04 -07:00
Anna Henningsen
687dbd8526
src: do not crash if ToggleAsyncHook fails during termination
In the termination case, we should not crash. There’s also no harm
being done by ignoring the termination exception here, since the
thread is about to be torn down anyway.

Also, add a guard against running this during shutdown. That is the
likely cause of https://github.com/nodejs/node/issues/34361.

Fixes: https://github.com/nodejs/node/issues/34361

PR-URL: https://github.com/nodejs/node/pull/34362
Fixes: https://github.com/nodejs/node/issues/27261
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2020-07-22 01:12:43 +02:00
Anna Henningsen
e2f9dc6e5a
src: remove user_data from TimerWrap
There’s no point in having an opaque user data pointer when we’re
already using `std::function`.

PR-URL: https://github.com/nodejs/node/pull/34252
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Zeyu Yang <himself65@outlook.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
2020-07-14 15:04:43 +02:00
James M Snell
e19a251824 src: replace InspectorTimer with TimerWrap utility
Signed-off-by: James M Snell <jasnell@gmail.com>

PR-URL: https://github.com/nodejs/node/pull/34186
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2020-07-05 14:57:03 -07:00
Daniel Bevenius
4a20cc937f
src: remove unused using declarations
This commit removes the unused using declarations reported by lint-cpp.

PR-URL: https://github.com/nodejs/node/pull/33268
Refs: https://github.com/nodejs/node/issues/29226
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Christian Clauss <cclauss@me.com>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
Reviewed-By: Beth Griggs <Bethany.Griggs@uk.ibm.com>
2020-05-28 10:02:14 -04:00
Anna Henningsen
6f9f546406
src: use env->RequestInterrupt() for inspector MainThreadInterface
This simplifies the code significantly, and removes the dependency of
the inspector code on the availability of a `MultiIsolatePlatform`
(by removing the dependency on a platform altogether).

It also fixes a memory leak that occurs when `RequestInterrupt()`
is used, but the interrupt handler is never called before the Isolate
is destroyed.

One downside is that this leads to a slight change in timing, because
inspector messages are not dispatched in a re-entrant way. This means
having to harden one test to account for that possibility by making
sure that the stack is always clear through a `setImmediate()`.
This does not affect the assertion made by the test, which is that
messages will not be delivered synchronously while other code is
executing.

https://github.com/nodejs/node/issues/32415

PR-URL: https://github.com/nodejs/node/pull/32523
Reviewed-By: Matheus Marchini <mat@mmarchini.me>
Reviewed-By: James M Snell <jasnell@gmail.com>
2020-04-10 17:47:14 +02:00
Anna Henningsen
32e3a6bb87
src: use env->RequestInterrupt() for inspector io thread start
This cleans up `Agent::RequestIoThreadStart()` significantly.

PR-URL: https://github.com/nodejs/node/pull/32523
Reviewed-By: Matheus Marchini <mat@mmarchini.me>
Reviewed-By: James M Snell <jasnell@gmail.com>
2020-04-10 17:47:12 +02:00
Anna Henningsen
583edd9526
src: fix cleanup hook removal for InspectorTimer
Fix this to account for the fact that `Stop()` may already have been
called from a cleanup hook when the `inspector::Agent` is deleted
along with the `Environment`, at which point cleanup hooks are no
longer available.

PR-URL: https://github.com/nodejs/node/pull/32523
Reviewed-By: Matheus Marchini <mat@mmarchini.me>
Reviewed-By: James M Snell <jasnell@gmail.com>
2020-04-10 17:47:11 +02:00
Ben Noordhuis
303e2fdc59
src: wrap HostPort in ExclusiveAccess
I found it exceedingly hard to figure out if there is a race condition
where one thread reads the inspector agent's HostPort's properties while
another modifies them concurrently.

I think the answer is "no, there isn't" but with this commit use sites
are forced to unwrap the object (and acquire the mutex in the process),
making it a great deal easier to reason about correctness.

PR-URL: https://github.com/nodejs/node/pull/31717
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: David Carlier <devnexen@gmail.com>
2020-02-13 20:53:36 +01:00
Anna Henningsen
3e79c004fd
inspector: properly shut down uv_async_t
Closing in the Agent destructor is too late, because that happens
when the Environment is destroyed, not when libuv handles are closed.

This fixes a situation in which the same libuv loop is re-used for
multiple Environment instances sequentially, e.g. in our cctest.

PR-URL: https://github.com/nodejs/node/pull/30612
Reviewed-By: Eugene Ostroukhov <eostroukhov@google.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2019-11-28 23:41:03 +01:00
Anna Henningsen
7e2a182d03
src: make WaitForInspectorDisconnect an exit hook
Run inspector cleanup code on Environment teardown.

This is part of a series of changes to make embedding easier, by
requiring fewer internal methods to build a fully functioning
Node.js instance.

PR-URL: https://github.com/nodejs/node/pull/30229
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Shelley Vohr <codebytere@gmail.com>
2019-11-06 23:26:04 +01:00