Skip to content

Commit

Permalink
inspector: only write coverage in fully bootstrapped Environments
Browse files Browse the repository at this point in the history
The NODE_V8_COVERAGE folder and the source map computation are setup
during pre-execution since they rely on environment variables as well
as JS states. Therefore, we need to give up serialization of JS
coverage profiles for Environments that have not go through
pre-execution. Currently this is only possible for Environments
created using the embedder API CreateEnvironment().

As a result we won't have JS coverage data for most cctests, but if
that proves to be necessary we could just run
lib/internal/main/environment.js for these Environments created for
cctests.

Fixes: #32912
Refs: 65e18a8
Refs: 5bf4372
8aa7ef7

PR-URL: #32960
Refs: 8aa7ef7
Reviewed-By: Richard Lau <[email protected]>
Reviewed-By: David Carlier <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Franziska Hinkelmann <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
  • Loading branch information
joyeecheung authored and BridgeAR committed Apr 28, 2020
1 parent ee3c461 commit fce8c4e
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/inspector_profiler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,16 @@ void V8CoverageConnection::WriteProfile(Local<String> message) {
HandleScope handle_scope(isolate);
Context::Scope context_scope(context);

// This is only set up during pre-execution (when the environment variables
// becomes available in the JS land). If it's empty, we don't have coverage
// directory path (which is resolved in JS land at the moment) either, so
// the best we could to is to just discard the profile and do nothing.
// This should only happen in half-baked Environments created using the
// embedder API.
if (env_->source_map_cache_getter().IsEmpty()) {
return;
}

// Get message.result from the response.
Local<Object> result;
if (!ParseProfile(env_, message, type()).ToLocal(&result)) {
Expand Down

0 comments on commit fce8c4e

Please sign in to comment.