From 7374c0c5e115f01f9a9853ea186d1002bd5cd19f Mon Sep 17 00:00:00 2001 From: Joyee Cheung Date: Wed, 24 Oct 2018 21:15:22 +0800 Subject: [PATCH] lib: fix code cache generation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit e7f710c1 broke the code cache generation since internalBinding is now passed in through the wrapper and cannot be redeclared. This patch fixes that. Refs: https://github.com/nodejs/node/issues/21563 PR-URL: https://github.com/nodejs/node/pull/23855 Reviewed-By: Michaƫl Zasso Reviewed-By: Refael Ackermann Reviewed-By: Colin Ihrig Reviewed-By: James M Snell --- lib/internal/bootstrap/cache.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/internal/bootstrap/cache.js b/lib/internal/bootstrap/cache.js index 41fe1e3a914ba0..6181228b033228 100644 --- a/lib/internal/bootstrap/cache.js +++ b/lib/internal/bootstrap/cache.js @@ -6,8 +6,9 @@ // cannot be tampered with even with --expose-internals const { - NativeModule, internalBinding + NativeModule } = require('internal/bootstrap/loaders'); +const { hasTracing } = process.binding('config'); function getCodeCache(id) { const cached = NativeModule.getCached(id); @@ -42,6 +43,16 @@ const cannotUseCache = [ 'internal/bootstrap/node' ].concat(depsModule); +// Skip modules that cannot be required when they are not +// built into the binary. +if (process.config.variables.v8_enable_inspector !== 1) { + cannotUseCache.push('inspector'); + cannotUseCache.push('internal/util/inspector'); +} +if (!hasTracing) { + cannotUseCache.push('trace_events'); +} + module.exports = { cachableBuiltins: Object.keys(NativeModule._source).filter( (key) => !cannotUseCache.includes(key)