diff options
author | Shobhit Chittora <schittora@paypal.com> | 2019-09-14 03:09:46 +0300 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2019-09-23 13:04:20 +0300 |
commit | fdd5d4ad4a228af6e5a7dc74ddf0e03dc5637254 (patch) | |
tree | a8c2ad59cd9222a516f3d4314195e41649cb7627 /lib/internal/bootstrap | |
parent | 4ef3ccbbe09d2f0cde8da078f9d2543332b152d2 (diff) |
bootstrap: add exception handling for profiler bootstrap
Add exception handling for the case when profile is
not bootstrapped when coverage is enabled.
Fixes: https://github.com/nodejs/node/issues/29542
PR-URL: https://github.com/nodejs/node/pull/29552
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Diffstat (limited to 'lib/internal/bootstrap')
-rw-r--r-- | lib/internal/bootstrap/pre_execution.js | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/internal/bootstrap/pre_execution.js b/lib/internal/bootstrap/pre_execution.js index d18d7099280..6e7d946458d 100644 --- a/lib/internal/bootstrap/pre_execution.js +++ b/lib/internal/bootstrap/pre_execution.js @@ -120,8 +120,16 @@ function setupCoverageHooks(dir) { const { resolve } = require('path'); const coverageDirectory = resolve(cwd, dir); const { sourceMapCacheToObject } = require('internal/source_map'); - internalBinding('profiler').setCoverageDirectory(coverageDirectory); - internalBinding('profiler').setSourceMapCacheGetter(sourceMapCacheToObject); + + if (process.features.inspector) { + internalBinding('profiler').setCoverageDirectory(coverageDirectory); + internalBinding('profiler').setSourceMapCacheGetter(sourceMapCacheToObject); + } else { + process.emitWarning('The inspector is disabled, ' + + 'coverage could not be collected', + 'Warning'); + return ''; + } return coverageDirectory; } |