-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
lib: fix TypeError when converting a detached buffer source #44020
lib: fix TypeError when converting a detached buffer source #44020
Conversation
bbb15af
to
ad6a134
Compare
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.
As a user, I would rather have the error than an empty buffer. The reason is that with the empty buffer, I just do not realize that something does not work as I expected.
I personally would like Node.js to have the same behavior as Web browser, especially in encoding APIs because many times I want to share the encoding logic between Web and server. Throwing TypeError feels confusing for me. |
Doesn't it look more like issue with |
ad6a134
to
6639bec
Compare
|
6639bec
to
89329e6
Compare
684f18a
to
a154022
Compare
Rebased and squashed |
a154022
to
2007eb5
Compare
Landed in 86088ab |
PR-URL: nodejs#44020 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]>
PR-URL: #44020 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]>
PR-URL: #44020 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]>
PR-URL: #44020 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]>
PR-URL: #44020 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]>
Currently
TextDecoder.decode
will throw TypeError when a detached buffer is given since it will try to convert a detached buffer into new buffer. This PR fixed TypeError by checking if a buffer is detached.