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

NODE_V8_COVERAGE does not fail gracefully when inspector is disabled #29542

Closed
addaleax opened this issue Sep 13, 2019 · 7 comments
Closed

NODE_V8_COVERAGE does not fail gracefully when inspector is disabled #29542

addaleax opened this issue Sep 13, 2019 · 7 comments
Labels
coverage Issues and PRs related to native coverage support. good first issue Issues that are suitable for first-time contributors. inspector Issues and PRs related to the V8 inspector protocol

Comments

@addaleax
Copy link
Member

  • Version: master
  • Subsystem: inspector
$ ./configure --without-intl
$ make -j4
$ NODE_V8_COVERAGE=/tmp/foo ./node -p 42

currently yields

internal/bootstrap/loaders.js:131
      mod = bindingObj[module] = getInternalBinding(module);
                                 ^

Error: No such module: profiler
    at internalBinding (internal/bootstrap/loaders.js:131:34)
    at setupCoverageHooks (internal/bootstrap/pre_execution.js:122:3)
    at prepareMainThreadExecution (internal/bootstrap/pre_execution.js:21:7)

I feel like this should a) print some kind of helpful message and b) maybe only print a warning or so instead of failing to execute the script.

@addaleax addaleax added inspector Issues and PRs related to the V8 inspector protocol coverage Issues and PRs related to native coverage support. labels Sep 13, 2019
@addaleax addaleax added good first issue Issues that are suitable for first-time contributors. mentor-available labels Sep 13, 2019
@Trott
Copy link
Member

Trott commented Sep 13, 2019

@bcoe

@shobhitchittora
Copy link
Contributor

@addaleax I'd like to take a look at this. Up for the mentor-available thing. 😄

@addaleax
Copy link
Member Author

@shobhitchittora Cool! As you can see from the stack trace, the function that sets up coverage is setupCoverageHooks in lib/internal/bootstrap/pre_execution.js, so that’s likely what you’d want to modify. There are also other examples of warnings being emitted in that file that you can take a look at.

As for contributing in general, https://github.com/nodejs/node/blob/master/doc/guides/contributing/pull-requests.md and https://github.com/nodejs/node/blob/master/doc/guides/writing-tests.md are probably helpful starting points. And if you run any trouble, feel free to ping me here or on Twitter or IRC (or generally feel free to ask a question in #node-dev on Freenode).

@shobhitchittora
Copy link
Contributor

shobhitchittora commented Sep 13, 2019

Thanks @addaleax for the code pointers. It's been some time since I pushed code here ( maybe in 2018 ), hope the guidelines are still the same.

Well! I see the docs and guidelines are much better organized now. Great work there!

@shobhitchittora
Copy link
Contributor

shobhitchittora commented Sep 13, 2019

I see that profiling logic has been recently moved to C++ land in #26874. Thinking as to why the reason the profiler binding is getting resolved here? Is something wrong with the bootstrapping here? @addaleax

@addaleax
Copy link
Member Author

addaleax commented Sep 13, 2019

@shobhitchittora What’s wrong is that the profiler internal binding from C++ isn’t available when the inspector is disabled – that’s what’s causing the exception in the output that I posted.

One way (of multiple ones) to address this might be to watch out for such an exception in JS, and handle it appropriately rather than letting it crash the process.

@shobhitchittora
Copy link
Contributor

Oh! Got it. I've added an try-catch block now and the output is as below -

>> NODE_V8_COVERAGE=/tmp/foo ./node -p 42
42
(node:12182) Warning: Profiler is not enabled.

Trott pushed a commit to shobhitchittora/node that referenced this issue Sep 23, 2019
exception handling for the case when profile is
not bootstrapped when coverage is enabled.

Fixes: nodejs#29542
targos pushed a commit that referenced this issue Sep 23, 2019
Add exception handling for the case when profile is
not bootstrapped when coverage is enabled.

Fixes: #29542

PR-URL: #29552
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
BridgeAR pushed a commit that referenced this issue Sep 25, 2019
Add exception handling for the case when profile is
not bootstrapped when coverage is enabled.

Fixes: #29542

PR-URL: #29552
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
coverage Issues and PRs related to native coverage support. good first issue Issues that are suitable for first-time contributors. inspector Issues and PRs related to the V8 inspector protocol
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants