-
Notifications
You must be signed in to change notification settings - Fork 9
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
Race condition in node 0.8.x #8
Comments
Actually, #7 will introduce a regression, because 0.8.x and 0.10.x have very different streaming APIs. This bug appeared because you're wrapping This behavior was changed in node 0.10.x. Since 0.10.x all stream are paused by default, until the first The fix I introduced in #7 is only good for 0.8.x streams, because calling This difference in Stream behavior was the main reason why people created modules like readable-stream, which simply mirror one particular Stream implementation in order to guarantee a stable streams base, regardless of what version of node.js you're using. So, #7 is not general enough and should not be merged, but I can see several ways to fix this bug:
|
As for the regression, here is the code to reproduce it: var mockSpawn = require('mock-spawn')
, mySpawn = mockSpawn();
mySpawn.setDefault(function(done) {
var self = this;
setTimeout(function() {
self.stdin.on('data', function(chunk) {
console.log('data:', String(chunk));
});
self.stdin.on('end', function() {
console.log('end!');
done(0);
});
}, 1000)
});
var proc = mySpawn();
proc.stdin.end('Hello world!'); In node.js 0.10.x this code should print
But with #7 it won't print anything. Note that this code is incompatible with node 0.8.x streams. |
Hi.
I found a race condition in
mock-spawn
that affects node 0.8.x users.Consider the following code:
It should print something like
But in node 0.8.x data gets emitted before
mySpawn
handler function is called, so nothing got printed.This bug can only be reproduced in node 0.8.x, because of a new streaming API that was introduced in node 0.10.x and took care of things like that.
The text was updated successfully, but these errors were encountered: