Skip to content

Commit ab47965

Browse files
committed
util: delay creation of debug context
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: #2248 Reviewed-By: Brian White <mscdex@mscdex.net> Reviewed-By: Michaël Zasso <mic.besace@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Christopher Monsanto <chris@monsan.to> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
1 parent c786d63 commit ab47965

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

lib/util.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
const uv = process.binding('uv');
44
const Buffer = require('buffer').Buffer;
5-
const Debug = require('vm').runInDebugContext('Debug');
65
const internalUtil = require('internal/util');
6+
var Debug;
77

88
const formatRegExp = /%[sdj%]/g;
99
exports.format = function(f) {
@@ -168,6 +168,7 @@ function arrayToHash(array) {
168168

169169

170170
function inspectPromise(p) {
171+
Debug = Debug || require('vm').runInDebugContext('Debug');
171172
var mirror = Debug.MakeMirror(p, true);
172173
if (!mirror.isPromise())
173174
return null;

0 commit comments

Comments
 (0)