-
Notifications
You must be signed in to change notification settings - Fork 30k
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
Encoding of child_process.exec.stdout changed from String to Buffer in v6.2.1 #7342
Comments
I doubt this was an intended change. Without having bisected, my guess would be that the change happened in #6764.
I would recommend not using |
Opened a pull request to add a known-issue test for this: #7375 |
I think the most sensible fix might be to revert that change from 6.x.x and put it in as a breaking change for 7.0.0 and update the documentation accordingly. |
I wonder if it is worth a second breaking change to v6 in order to do the revert. Working around this is straightforward, and the bug in question goes against the primary use case of |
To work around it while preserving the old behavior, the default case will need to convert the string to a Buffer on every Or is there a different workaround you envision? |
There probably would be a performance hit. Not sure how significant. To reiterate, I don't think handling individual |
I'll try to carve out a little time to code it up and benchmark to see the performance implications. As far as flip-flopping, since it's flip-flopping on undocumented behavior that is definitely not the intended usage of
While not ideal, I think that's OK if it's the only performant way to fix the EDIT: Oh, wait, I suspect (now that I think about it) that you are suggesting just leaving things as they are and sorta kinda declaring this Not-A-Bug? That works for me too, but since there is at least one example of Real World Breakage due to this, I am more inclined towards revert-and-reintroduce-at-semver-major-time. |
Well, this is surprising but I guess that's why we benchmark: Reverting the fix in Without that change:
With that change:
/cc @mscdex on the benchmark just in case I'm Doing Something Wrong Benefits of this fix:
Downside:
|
PR-URL: nodejs#7375 Refs: nodejs#7342 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
A previous fix for a `maxBuffer` bug resulted in a change to the argument type for the `data` event on `child.stdin` and `child.stdout` when using `child_process.exec()`. This fixes the `maxBuffer` bug in a way that does not have that side effect. Fixes: nodejs#7342 Refs: nodejs#1901
Fixed via #7391 |
A previous fix for a `maxBuffer` bug resulted in a change to the argument type for the `data` event on `child.stdin` and `child.stdout` when using `child_process.exec()`. This fixes the `maxBuffer` bug in a way that does not have that side effect. PR-URL: #7391 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Jackson Tian <shyvo1987@gmail.com> Fixes: #7342 Refs: #1901
A previous fix for a `maxBuffer` bug resulted in a change to the argument type for the `data` event on `child.stdin` and `child.stdout` when using `child_process.exec()`. This fixes the `maxBuffer` bug in a way that does not have that side effect. PR-URL: #7391 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Jackson Tian <shyvo1987@gmail.com> Fixes: #7342 Refs: #1901
A previous fix for a `maxBuffer` bug resulted in a change to the argument type for the `data` event on `child.stdin` and `child.stdout` when using `child_process.exec()`. This fixes the `maxBuffer` bug in a way that does not have that side effect. PR-URL: #7391 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Jackson Tian <shyvo1987@gmail.com> Fixes: #7342 Refs: #1901
A previous fix for a `maxBuffer` bug resulted in a change to the argument type for the `data` event on `child.stdin` and `child.stdout` when using `child_process.exec()`. This fixes the `maxBuffer` bug in a way that does not have that side effect. PR-URL: #7391 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Jackson Tian <shyvo1987@gmail.com> Fixes: #7342 Refs: #1901
A previous fix for a `maxBuffer` bug resulted in a change to the argument type for the `data` event on `child.stdin` and `child.stdout` when using `child_process.exec()`. This fixes the `maxBuffer` bug in a way that does not have that side effect. PR-URL: #7391 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Jackson Tian <shyvo1987@gmail.com> Fixes: #7342 Refs: #1901
Somewhere between node v6.2.0 and v6.2.1 the encoding of the data passed to the 'on data' callback for the child_process.exec.stdout stream seems to have changed from String to Buffer.
Was this an intentional change, and what is the recommended way of setting the encoding for the exec stdout/stdio stream?
Thanks
Code example:
with v6.2.0, output is
data: string false
with v6.2.1, output is
data: object true
The text was updated successfully, but these errors were encountered: