Commit Graph

5 Commits

Author SHA1 Message Date
Rich Trott
330f25ef82 test: prepare for consistent comma-dangle lint rule
Make changes so that tests will pass when the comma-dangle settings
applied to the rest of the code base are also applied to tests.

PR-URL: https://github.com/nodejs/node/pull/37930
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Derek Lewis <DerekNonGeneric@inf.is>
2021-04-01 23:14:29 -07: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
0279c2f28b test: fix flaky test-inspector-connect-main-thread
Previously, the test waited for a (any) message from the workers,
and then attached another event listener to a specific kind of
message. However, it was possible that the second listener was
attached after the Worker had already exited, thus never receiving
the message it was supposed to receive. (This is the race condition
here – usually, the Worker thread would exit *after* the second
listener was attached.)

Solve this by keeping a single `'message'` event listener attached
to the worker instance during its entire lifetime.

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

PR-URL: https://github.com/nodejs/node/pull/31637
Reviewed-By: Eugene Ostroukhov <eostroukhov@google.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2020-02-07 16:03:54 -10:00
Anna Henningsen
3adec43791 test: fix flaky test-inspector-connect-main-thread
Using `console.log()` likely interferes with the functionality of the
test, which also checks the interaction between inspector
and `console.log()` as part of the test. Using `process._rawDebug()`
solves that issue.

Refs: https://github.com/nodejs/node/pull/28870
Refs: https://github.com/nodejs/node/pull/29582

PR-URL: https://github.com/nodejs/node/pull/29588
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
2019-09-17 11:11:55 -07:00
Eugene Ostroukhov
3d841fe20d inspector: new API - Session.connectToMainThread
This API is designed to enable worker threads use Inspector protocol
on main thread (and other workers through NodeWorker domain).

Note that worker can cause dead lock by suspending itself. I will
work on a new API that will allow workers to be hidden from the
inspector.

Fixes: https://github.com/nodejs/node/issues/28828
PR-URL: https://github.com/nodejs/node/pull/28870
Reviewed-By: Aleksei Koziatinskii <ak239spb@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
2019-09-16 09:01:55 -07:00