From ab479659c789f938f0560b49167ba85ef825f1ba Mon Sep 17 00:00:00 2001 From: Ali Ijaz Sheikh Date: Sat, 25 Jul 2015 06:01:24 -0700 Subject: [PATCH] util: delay creation of debug context MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We need the debug context to be able to inspect promises. However, this is very expensive and should not be done on default startup. PR-URL: https://github.com/nodejs/io.js/pull/2248 Reviewed-By: Brian White Reviewed-By: Michaƫl Zasso Reviewed-By: Ben Noordhuis Reviewed-By: Christopher Monsanto Reviewed-By: Colin Ihrig --- lib/util.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/util.js b/lib/util.js index 37f2a07ba27a4f..136a66a6c1c0e8 100644 --- a/lib/util.js +++ b/lib/util.js @@ -2,8 +2,8 @@ const uv = process.binding('uv'); const Buffer = require('buffer').Buffer; -const Debug = require('vm').runInDebugContext('Debug'); const internalUtil = require('internal/util'); +var Debug; const formatRegExp = /%[sdj%]/g; exports.format = function(f) { @@ -168,6 +168,7 @@ function arrayToHash(array) { function inspectPromise(p) { + Debug = Debug || require('vm').runInDebugContext('Debug'); var mirror = Debug.MakeMirror(p, true); if (!mirror.isPromise()) return null;