'return require("vm").runInThisContext(' +
JSON.stringify(body) + ', { filename: ' +
JSON.stringify(name) + ' });\n';
- var result = module._compile(script, name + '-wrapper');
- if (process._print_eval) console.log(result);
+ // Defer evaluation for a tick. This is a workaround for deferred
+ // events not firing when evaluating scripts from the command line,
+ // see https://github.com/nodejs/io.js/issues/1600.
+ process.nextTick(function() {
+ var result = module._compile(script, name + '-wrapper');
+ if (process._print_eval) console.log(result);
+ });
}
function createWritableStdioStream(fd) {
at Object.exports.runInThisContext (vm.js:*)
at Object.<anonymous> ([eval]-wrapper:*:*)
at Module._compile (module.js:*:*)
- at evalScript (node.js:*:*)
- at startup (node.js:*:*)
at node.js:*:*
+ at doNTCallback0 (node.js:*:*)
+ at process._tickCallback (node.js:*:*)
42
42
[eval]:1
at Object.exports.runInThisContext (vm.js:*)
at Object.<anonymous> ([eval]-wrapper:*:*)
at Module._compile (module.js:*:*)
- at evalScript (node.js:*:*)
- at startup (node.js:*:*)
at node.js:*:*
+ at doNTCallback0 (node.js:*:*)
+ at process._tickCallback (node.js:*:*)
[eval]:1
throw new Error("hello")
^
at Object.exports.runInThisContext (vm.js:*)
at Object.<anonymous> ([eval]-wrapper:*:*)
at Module._compile (module.js:*:*)
- at evalScript (node.js:*:*)
- at startup (node.js:*:*)
at node.js:*:*
+ at doNTCallback0 (node.js:*:*)
+ at process._tickCallback (node.js:*:*)
100
[eval]:1
var x = 100; y = x;
at Object.exports.runInThisContext (vm.js:*)
at Object.<anonymous> ([eval]-wrapper:*:*)
at Module._compile (module.js:*:*)
- at evalScript (node.js:*:*)
- at startup (node.js:*:*)
at node.js:*:*
+ at doNTCallback0 (node.js:*:*)
+ at process._tickCallback (node.js:*:*)
[eval]:1
var ______________________________________________; throw 10
^
at Object.exports.runInThisContext (vm.js:*)
at Object.<anonymous> ([stdin]-wrapper:*:*)
at Module._compile (module.js:*:*)
- at evalScript (node.js:*:*)
- at Socket.<anonymous> (node.js:*:*)
- at emitNone (events.js:*:*)
- at Socket.emit (events.js:*:*)
- at endReadableNT (_stream_readable.js:*:*)
- at doNTCallback2 (node.js:*:*)
+ at node.js:*:*
+ at doNTCallback0 (node.js:*:*)
at process._tickCallback (node.js:*:*)
42
42
at Object.exports.runInThisContext (vm.js:*)
at Object.<anonymous> ([stdin]-wrapper:*:*)
at Module._compile (module.js:*:*)
- at evalScript (node.js:*:*)
- at Socket.<anonymous> (node.js:*:*)
- at emitNone (events.js:*:*)
- at Socket.emit (events.js:*:*)
- at endReadableNT (_stream_readable.js:*:*)
- at doNTCallback2 (node.js:*:*)
+ at node.js:*:*
+ at doNTCallback0 (node.js:*:*)
+ at process._tickCallback (node.js:*:*)
[stdin]:1
throw new Error("hello")
at Object.exports.runInThisContext (vm.js:*)
at Object.<anonymous> ([stdin]-wrapper:*:*)
at Module._compile (module.js:*:*)
- at evalScript (node.js:*:*)
- at Socket.<anonymous> (node.js:*:*)
- at emitNone (events.js:*:*)
- at Socket.emit (events.js:*:*)
- at endReadableNT (_stream_readable.js:*:*)
- at doNTCallback2 (node.js:*:*)
+ at node.js:*:*
+ at doNTCallback0 (node.js:*:*)
+ at process._tickCallback (node.js:*:*)
100
[stdin]:1
at Object.exports.runInThisContext (vm.js:*)
at Object.<anonymous> ([stdin]-wrapper:*:*)
at Module._compile (module.js:*:*)
- at evalScript (node.js:*:*)
- at Socket.<anonymous> (node.js:*:*)
- at emitNone (events.js:*:*)
- at Socket.emit (events.js:*:*)
- at endReadableNT (_stream_readable.js:*:*)
- at doNTCallback2 (node.js:*:*)
+ at node.js:*:*
+ at doNTCallback0 (node.js:*:*)
+ at process._tickCallback (node.js:*:*)
[stdin]:1
var ______________________________________________; throw 10
--- /dev/null
+'use strict';
+
+const common = require('../common');
+const assert = require('assert');
+const spawn = require('child_process').spawn;
+
+const child = spawn(process.execPath, ['-e', `
+ const server = require('net').createServer().listen(0);
+ server.once('listening', server.close);
+`]);
+
+child.once('exit', common.mustCall(function(exitCode, signalCode) {
+ assert.equal(exitCode, 0);
+ assert.equal(signalCode, null);
+}));