Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

inspector: allow opening inspector when NODE_V8_COVERAGE is set #46113

Merged
merged 1 commit into from
Jan 29, 2023

Conversation

MoLow
Copy link
Member

@MoLow MoLow commented Jan 5, 2023

Fixes: #46110

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. inspector Issues and PRs related to the V8 inspector protocol needs-ci PRs that need a full CI run. labels Jan 5, 2023
@MoLow MoLow removed the c++ Issues and PRs that require attention from people who are familiar with C++. label Jan 5, 2023
@MoLow MoLow force-pushed the fix-inspector-with-c8-coverage branch from 868efc8 to 44f774c Compare January 5, 2023 22:27
@MoLow MoLow changed the title src: allow opening inspector when NODE_V8_COVERAGE is set inspector: allow opening inspector when NODE_V8_COVERAGE is set Jan 5, 2023
@MoLow
Copy link
Member Author

MoLow commented Jan 5, 2023

CC @nodejs/inspector

@MoLow MoLow added the request-ci Add this label to start a Jenkins CI on a PR. label Jan 6, 2023
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jan 6, 2023
@nodejs-github-bot
Copy link
Collaborator

@bnoordhuis
Copy link
Member

I kind of feel this is more a hack or workaround than a proper fix, possibly with undesirable side effects.

isEnabled() returns true because the inspector agent thread is running. Code coverage creates its own inspector session which in turn starts the agent thread.

Maybe the io_ != nullptr check here is wrong, that's the "is the agent thread already running?" check:

node/src/inspector_agent.cc

Lines 942 to 946 in 513c151

bool Agent::IsActive() {
if (client_ == nullptr)
return false;
return io_ != nullptr || client_->IsActive();
}

Or maybe it's sometimes needed - but in this case it gives the wrong behavior.

@cola119
Copy link
Member

cola119 commented Jan 9, 2023

CMIIW, code coverage creates its own inspector session but doesn't start the agent thread while inspector.open() starts the agent thread. That means isEnabled() should return true when the agent thread is running, the condition when the inspector io (Agent::io_) exists. I've confirmed all tests are green.

diff --git a/src/inspector_js_api.cc b/src/inspector_js_api.cc
index 3595536c78..1602faf1bd 100644
--- a/src/inspector_js_api.cc
+++ b/src/inspector_js_api.cc
@@ -273,7 +273,7 @@ static void RegisterAsyncHookWrapper(const FunctionCallbackInfo<Value>& args) {
 
 void IsEnabled(const FunctionCallbackInfo<Value>& args) {
   Environment* env = Environment::GetCurrent(args);
-  args.GetReturnValue().Set(InspectorEnabled(env));
+  args.GetReturnValue().Set(env->inspector_agent()->IsListening());
 }
 
 void Open(const FunctionCallbackInfo<Value>& args) {

@MoLow MoLow force-pushed the fix-inspector-with-c8-coverage branch from 44f774c to 4d2eca7 Compare January 28, 2023 21:39
@MoLow
Copy link
Member Author

MoLow commented Jan 28, 2023

thanks @cola119! I have pushed your suggestion

@MoLow MoLow added the request-ci Add this label to start a Jenkins CI on a PR. label Jan 29, 2023
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jan 29, 2023
@nodejs-github-bot
Copy link
Collaborator

@MoLow MoLow added the commit-queue Add this label to land a pull request using GitHub Actions. label Jan 29, 2023
@nodejs-github-bot nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Jan 29, 2023
@nodejs-github-bot nodejs-github-bot merged commit 7b4cc58 into nodejs:main Jan 29, 2023
@nodejs-github-bot
Copy link
Collaborator

Landed in 7b4cc58

@MoLow MoLow deleted the fix-inspector-with-c8-coverage branch January 29, 2023 21:47
ruyadorno pushed a commit that referenced this pull request Feb 1, 2023
PR-URL: #46113
Fixes: #46110
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: James M Snell <[email protected]>
@ruyadorno ruyadorno mentioned this pull request Feb 1, 2023
juanarbol pushed a commit that referenced this pull request Mar 3, 2023
PR-URL: #46113
Fixes: #46110
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: James M Snell <[email protected]>
@juanarbol juanarbol mentioned this pull request Mar 3, 2023
juanarbol pushed a commit that referenced this pull request Mar 3, 2023
PR-URL: #46113
Fixes: #46110
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: James M Snell <[email protected]>
juanarbol pushed a commit that referenced this pull request Mar 5, 2023
PR-URL: #46113
Fixes: #46110
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
inspector Issues and PRs related to the V8 inspector protocol needs-ci PRs that need a full CI run.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

inspector.url()/open() does not work if NODE_V8_COVERAGE is set
6 participants