-
Notifications
You must be signed in to change notification settings - Fork 29.7k
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
tls: support Uint8Arrays for protocol list buffers #11984
Conversation
b29667f
to
5849db1
Compare
Why is this one semver-minor when the others are labeled as semver-major? |
@mscdex .. the other PRs had error message changes, this one does not. |
@@ -56,3 +56,17 @@ assert.throws(() => tls.createSecurePair({}), | |||
assert(buffer.equals(Buffer.from('abcd'))); | |||
assert(out.NPNProtocols.equals(Buffer.from('efgh'))); | |||
} | |||
|
|||
{ | |||
const buffer = new Uint8Array([...Buffer.from('abcd')]); |
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.
Why using the spread operator? If I'm not wrong passing a buffer to the Uint8Array
constructor (new Uint8Array(Buffer.from('abcd'))
) works.
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.
For this case, indeed it would work. Passing a Buffer to Uint8Array makes the Uint8Array use the identical underlying ArrayBuffer, which at times may not be desirable. But in this case we are creating a new Buffer every time so it should be fine.
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.
@TimothyGu AFAIK memory is copied to the TypedArray
not shared.
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.
@lpinca, heh I was mistaken. In that case, yeah there's no reason to use spread syntax...
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.
@lpinca @TimothyGu right, thanks for pointing out. fixed!
5849db1
to
dd07fc0
Compare
Landed in c3efe72 |
PR-URL: #11984 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
This needs to be manually backported to v7.x |
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)