Browse Source

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: https://github.com/nodejs/io.js/pull/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>
v4.0.0-rc
Ali Ijaz Sheikh 10 years ago
parent
commit
ab479659c7
  1. 3
      lib/util.js

3
lib/util.js

@ -2,8 +2,8 @@
const uv = process.binding('uv'); const uv = process.binding('uv');
const Buffer = require('buffer').Buffer; const Buffer = require('buffer').Buffer;
const Debug = require('vm').runInDebugContext('Debug');
const internalUtil = require('internal/util'); const internalUtil = require('internal/util');
var Debug;
const formatRegExp = /%[sdj%]/g; const formatRegExp = /%[sdj%]/g;
exports.format = function(f) { exports.format = function(f) {
@ -168,6 +168,7 @@ function arrayToHash(array) {
function inspectPromise(p) { function inspectPromise(p) {
Debug = Debug || require('vm').runInDebugContext('Debug');
var mirror = Debug.MakeMirror(p, true); var mirror = Debug.MakeMirror(p, true);
if (!mirror.isPromise()) if (!mirror.isPromise())
return null; return null;

Loading…
Cancel
Save