-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
child_process: make the maxBuffer correct with unicode #1902
Conversation
Ref: #1901 |
caculate byte length maybe make performance slow. Would like to hear more suggestion. |
Ditto on the |
d609ac1
to
d90d98c
Compare
Thanks @cjihrig @trevnorris . Use |
@@ -230,7 +230,11 @@ exports.execFile = function(file /* args, options, callback */) { | |||
} | |||
|
|||
child.stdout.addListener('data', function(chunk) { | |||
stdoutLen += chunk.length; | |||
if (!encoding) { |
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.
According to the docs, the unit of maxBuffer
is bytes, so I think these should unconditionally use Buffer.byteLength()
.
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.
@JacksonTian missed this one.
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.
when don't set the encoding, the chunk
is a buffer.
@cjihrig updated. |
ping @nodejs/collaborators |
LGTM |
CI is not happy. |
oops. err not found in windows.... |
the windows doesn't like unicode. hmmm. |
I think maybe reached an edge case for windows platform. |
Anyone can help me to restart the CI? |
The test failures seem to be related to a known issue on Windows - nodejs/node-v0.x-archive#7940. @piscisaureus is this something that can be skipped on Windows during testing? |
can we skip the test case for win32? ping @piscisaureus |
You can probably skip the test case with something like the crypto skip, but with |
anyone can help me to restart the CI? |
I think what @piscisaureus is getting at is that partial character sequences throw off the length calculation; the Apart from that stipulation the patch looks correct to me. It's rather inefficient though: we first convert from bytes to characters and then we convert that back to bytes for the length calculation. |
@bnoordhuis We can don't set encoding, so don't use |
aa6a9d7
to
8e08e84
Compare
I think you will still need a I don't think we can just remove the |
8e08e84
to
0bc6cdd
Compare
0bc6cdd
to
8d5a444
Compare
With the commit bfb2cd0 be landed, the PR can be implemented more light-weight. |
8d5a444
to
3e22109
Compare
maxBuffer: 10 | ||
}, common.mustCall(function(err, stdout, stderr) { | ||
assert(err); | ||
assert.equal(err.message, 'stdout maxBuffer exceeded'); |
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.
Can you use assert.strictEqual()
here. Also, you can drop the first assertion.
LGTM. This should hopefully avoid any encoding issues. @bnoordhuis @piscisaureus @trevnorris thoughts? |
The maxLen just caculate the string length, but to unicode string, the string size is less than buffer size.
3e22109
to
937452c
Compare
Would it be possible to get another round of reviews from some combination of @bnoordhuis @piscisaureus and @trevnorris ? It would be nice to see this finally land if the objections have been sufficiently addressed. (And if not, it would be nice to have the objections documented or reiterated.) |
Nit: Can you add |
Nit: Can you find a way to shorten the first line of the commit message so that it is 50 characters or less? |
For the test would it be possible to spawn a child node process and write to its stderr/stdout? That should work for all platforms. |
It looks like the test still needs an update. |
bfb2cd0 was reverted, this issue needs hold. |
7da4fd4
to
c7066fb
Compare
I believe this can be closed now given that #6764 landed. |
The maxLen just caculate the string length, but to unicode string,
the string size is less than buffer size.