Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

src: fix deferred events not working with -e #1793

Merged
merged 4 commits into from
May 26, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
lib/punycode.js
test/addons/doc-*/
test/fixtures
test/**/node_modules
test/parallel/test-fs-non-number-arguments-throw.js
9 changes: 7 additions & 2 deletions src/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -558,8 +558,13 @@
'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) {
Expand Down
2 changes: 1 addition & 1 deletion test/addons/async-hello-world/binding.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ void AfterAsync(uv_work_t* r) {
delete req;

if (try_catch.HasCaught()) {
FatalException(try_catch);
FatalException(isolate, try_catch);
}
}

Expand Down
1 change: 0 additions & 1 deletion test/message/eval_messages.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
'use strict';
// USE OR OTHER DEALINGS IN THE SOFTWARE.

var common = require('../common');
var assert = require('assert');
Expand Down
16 changes: 8 additions & 8 deletions test/message/eval_messages.out
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ SyntaxError: Strict mode code may not include a with statement
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
Expand All @@ -19,9 +19,9 @@ 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:*:*)
[eval]:1
throw new Error("hello")
^
Expand All @@ -30,9 +30,9 @@ 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;
Expand All @@ -42,9 +42,9 @@ ReferenceError: y is not defined
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
^
Expand Down
1 change: 0 additions & 1 deletion test/message/stdin_messages.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
'use strict';
// USE OR OTHER DEALINGS IN THE SOFTWARE.

var common = require('../common');
var assert = require('assert');
Expand Down
35 changes: 11 additions & 24 deletions test/message/stdin_messages.out
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,8 @@ SyntaxError: Strict mode code may not include a with statement
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
Expand All @@ -25,12 +21,9 @@ 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:*:*)

[stdin]:1
throw new Error("hello")
Expand All @@ -40,12 +33,9 @@ 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
Expand All @@ -56,12 +46,9 @@ ReferenceError: y is not defined
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
Expand Down
15 changes: 15 additions & 0 deletions test/parallel/test-cli-eval-event.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
'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);
}));
1 change: 0 additions & 1 deletion test/parallel/test-event-emitter-listeners-side-effects.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
'use strict';
// USE OR OTHER DEALINGS IN THE SOFTWARE.

var common = require('../common');
var assert = require('assert');
Expand Down
1 change: 0 additions & 1 deletion test/parallel/test-event-emitter-listeners.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
'use strict';
// USE OR OTHER DEALINGS IN THE SOFTWARE.

var common = require('../common');
var assert = require('assert');
Expand Down