Skip to content

NODE_V8_COVERAGE does not fail gracefully when inspector is disabled #29542

Description

@addaleax
  • 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.

Activity

  1. added
    inspectorIssues and PRs related to the V8 inspector protocol.
    coverageIssues and PRs related to Node.js code coverage support.
    good first issueIssues that are suitable for first-time contributors.
    on Sep 13, 2019
  2. Trott commented on Sep 13, 2019

    @Trott
    Member
  3. shobhitchittora commented on Sep 13, 2019

    @shobhitchittora
    Contributor

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

  4. addaleax commented on Sep 13, 2019

    @addaleax
    MemberAuthor

    @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).

  5. shobhitchittora commented on Sep 13, 2019

    @shobhitchittora
    Contributor

    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!

  6. shobhitchittora commented on Sep 13, 2019

    @shobhitchittora
    Contributor

    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

  7. addaleax commented on Sep 13, 2019

    @addaleax
    MemberAuthor

    @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.

  8. shobhitchittora commented on Sep 13, 2019

    @shobhitchittora
    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.
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    coverageIssues and PRs related to Node.js code coverage support.good first issueIssues that are suitable for first-time contributors.inspectorIssues and PRs related to the V8 inspector protocol.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions