diff options
author | Shobhit Chittora <schittora@paypal.com> | 2019-09-14 05:39:46 +0530 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2019-09-23 12:04:20 +0200 |
commit | fdd5d4ad4a228af6e5a7dc74ddf0e03dc5637254 (patch) | |
tree | a8c2ad59cd9222a516f3d4314195e41649cb7627 /lib | |
parent | 4ef3ccbbe09d2f0cde8da078f9d2543332b152d2 (diff) | |
download | android-node-v8-fdd5d4ad4a228af6e5a7dc74ddf0e03dc5637254.tar.gz android-node-v8-fdd5d4ad4a228af6e5a7dc74ddf0e03dc5637254.tar.bz2 android-node-v8-fdd5d4ad4a228af6e5a7dc74ddf0e03dc5637254.zip |
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')
-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 d18d709928..6e7d946458 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; } |