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: fix inspector::Agent::HasConnectedSessions #20614

Closed
wants to merge 1 commit into from

Conversation

helloshuangzi
Copy link
Contributor

@helloshuangzi helloshuangzi commented May 8, 2018

In Agent::HasConnectedSessions, return false if client_ is nullptr.
That's possible when inspector setting is skipped for embedding/addon scenarios.
It makes the code more robust at least, otherwise, crash will happen here.

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • commit message follows commit guidelines

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. dont-land-on-v4.x inspector Issues and PRs related to the V8 inspector protocol labels May 8, 2018
@eugeneo
Copy link
Contributor

eugeneo commented May 9, 2018

It is possible to build Node without the inspector. Should that mode be used for embedding?

@helloshuangzi
Copy link
Contributor Author

helloshuangzi commented May 9, 2018

@eugeneo Thanks for the quick response!
Yes, I believe that helps for embedding, but I still think this change should be there to make the code more robust.
The problem also happens for addon users, who can't control the build mode of node.
Actually, I am working on re-implementing napajs worker::WorkerThreadFunc by node public API. There is no public API available now to set up inspector, and I don't want to enable inspector at the current stage.

@eugeneo
Copy link
Contributor

eugeneo commented May 9, 2018

I am still not comfortable with this fix, because it means the rest of the Node is unaware that the inspector might be missing. I assume the issue you are facing is because of WaitForInspectorDisconnect call in node.cc. Would it be possible not to call it instead? I think we should not reference env->inspector_agent at all if the Inspector is not properly setup.

@helloshuangzi
Copy link
Contributor Author

Thanks for the suggestion, but I am not calling WaitForInspectorDisconnect.
Actually, the issue is from the below stack.

LoadEnvironment(&env);
-consoleCall
--InspectorEnabled(Environment* env)
---HasConnectedSessions()

@eugeneo
Copy link
Contributor

eugeneo commented May 9, 2018

Then it looks like console should not be pinging inspector when the inspector is n/a. IMHO, the best fix would still be to compile without the inspector altogether if it is not needed.

Anyway, I will not be blocking this PR.

@helloshuangzi
Copy link
Contributor Author

napajs works as a node.js addon. As same as other addon usage, we can't control the building mode of node.
@eugeneo, please let me know if you have a better way for addon scenarios like ours.

@eugeneo
Copy link
Contributor

eugeneo commented May 9, 2018

@helloshuangzi try ./configure --without-inspector when building Node.

@helloshuangzi
Copy link
Contributor Author

@eugeneo I know that flag, and it did help embedding scenarios if it works, but not for addon scenarios. Because the addon will depend on a self-built node to run it. It would be a significant drawback if an addon can't run with the official release version of node.js.

@addaleax
Copy link
Member

addaleax commented May 9, 2018

IMHO, the best fix would still be to compile without the inspector altogether if it is not needed.

@eugeneo I think that’s not a viable long-term solution for embedders.

@eugeneo
Copy link
Contributor

eugeneo commented May 9, 2018

@addaleax inspector::Agent::Start should always be called if the inspector::Agent instance had been created (i.e. if the Node was built with the inspector support). I will work on that fix when I have some time.

As I said, I am not blocking this PR.

@addaleax
Copy link
Member

@addaleax addaleax added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label May 10, 2018
@helloshuangzi
Copy link
Contributor Author

I noticed there were unsuccessful checks in the last CI, which can also be found for other PRs yesterday. I think it may got fixed by newly landed commits, so I just rebased it by the latest master. Please let me know if I should not do this after a collaborator started CI.

@eugeneo
Copy link
Contributor

eugeneo commented May 11, 2018

@addaleax
Copy link
Member

Landed in 34ca9f3

@addaleax addaleax closed this May 14, 2018
addaleax pushed a commit that referenced this pull request May 14, 2018
PR-URL: #20614
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
addaleax pushed a commit that referenced this pull request May 14, 2018
PR-URL: #20614
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
helloshuangzi added a commit to helloshuangzi/node that referenced this pull request May 14, 2018
PR-URL: nodejs#20614
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
@helloshuangzi helloshuangzi deleted the inspector branch May 14, 2018 17:47
@addaleax addaleax mentioned this pull request May 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. c++ Issues and PRs that require attention from people who are familiar with C++. inspector Issues and PRs related to the V8 inspector protocol
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants