-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Fix output buffer is imcomplete working in child_process #1834
Conversation
}); | ||
|
||
emitter.on('done', function() { | ||
if (!options.watch && !options.directory) { | ||
if (!options.watch && !options.directory && !asyncWaiting) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isn't asyncWaiting
always true now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
asyncWaiting
is initialized on false when called getEmitter()
.
https://github.com/sass/node-sass/pull/1834/files#diff-c19ab2481e2703fcf0d2808f4c762f63R147
I read project source code, emit log
event only stdout case ( is it right? ).
So that, asyncWaiting
set to be true only emitted log
event.
Please advise if there are other concerns that you need to worry about. thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is right. I believe we always want to exit when emitter.log is called. This is what happens when you call the node-sass cli. If I understand correctly all we need to do is
emitter.on('log', stdout.write);
Am I missing something?
https://www.npmjs.com/package/stdout-stream seems like a better alternative than writing out own stdout stream lib. |
I replaced out stdout lib to suggested package, it also works fine! |
It works fine, but Travis CI is down for some testings... |
I'm sorry the issue here is not clear. Either the problem is related to
It's because |
Yes, I think so. However, |
OK I did some digging. You're correct that the issue is due how process.exit works.
I see ways to solve this:
|
Thank you for your advice. I replaced to And I removed exiting in |
@@ -161,13 +163,12 @@ function getEmitter() { | |||
}); | |||
|
|||
emitter.on('log', function(data) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
emitter.on('log', stdout.write)
@@ -161,13 +163,12 @@ function getEmitter() { | |||
}); | |||
|
|||
emitter.on('log', function(data) { | |||
console.log(data); | |||
// In nodejs <= 7.1.0, console.log cannot write output larger than 8275 bytes data. | |||
stdout.write(data); | |||
}); | |||
|
|||
emitter.on('done', function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please delete the emitter.on('done'
block all together.
@@ -150,7 +152,7 @@ function getEmitter() { | |||
} | |||
console.error(err); | |||
if (!options.watch) { | |||
process.exit(1); | |||
exit(1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
process.exit
is fine here because console.error
is synchronous.
https://github.com/sass/node-sass/pull/1834/files#diff-c19ab2481e2703fcf0d2808f4c762f63R165 Use |
@@ -56,6 +56,7 @@ | |||
"async-foreach": "^0.1.3", | |||
"chalk": "^1.1.1", | |||
"cross-spawn": "^3.0.0", | |||
"exit": "^0.1.2", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove.
@@ -47,21 +47,14 @@ module.exports = function(options, emitter) { | |||
var stdin = options.stdin; | |||
|
|||
var success = function(result) { | |||
var todo = 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The done
still needs to be fired. It's used in other places. Please undo these changes and just remove
emitter.on('done', function() {
// noop
});
Thank you for your work and patience. I'll merge this when CI is happy. |
Fix premature exit before the output stream is fully flushed
When I send a large buffer, over 50KB's CSS string, working in
child_process.spawn
,node-sass
outputs only partial strings.Certainly, it is caused by nodejs's
console.log
max size.nodejs/node#9546
So I modified to send output by continuous partial strings, its asynchronous.
This PR will fix this issue: #1823.