v8 module: allow TypedArray and DataView#23953
Conversation
refack
left a comment
There was a problem hiding this comment.
Nits made me ask a question about timing.
test/parallel/test-v8-serdes.js
Outdated
test/parallel/test-v8-serdes.js
Outdated
There was a problem hiding this comment.
Could these be const length2 and const buf2 please?
Recycling variables should be avoided.
test/parallel/test-v8-serdes.js
Outdated
There was a problem hiding this comment.
Could this be const arrayBufferViewsLength instead.
.
.
.
Which made be think isn't there a race here?
Is the callbacks guaranteed to be in order?
At minimum this should be documented in a comment
There was a problem hiding this comment.
Is the callbacks guaranteed to be in order?
Yes. We have only one HostObject so that the callback will be called only once.
I think v8.Serializer.writeRawBytes() being expected to be called inside of the callback of _writeHostObject makes the test a bit confusing. I'm going to refactor this.
|
@oyyd as alway thank you for the contribution. While reviewing the code and looking at cases of variable recycling I found that I don't understand the operation order guarantee. |
test/parallel/test-v8-serdes.js
Outdated
There was a problem hiding this comment.
Maybe simplest solution is to add a sentinel:
let has_writeHostObjectCalled = false;the in _writeHostObject
has_writeHostObjectCalled = true;the first line of _readHostObject
assert.ok(has_writeHostObjectCalled);There was a problem hiding this comment.
or dual use arrayBufferViewsLength - initialise it to false, and then assert
des._readHostObject = common.mustCall(() => {
assert.notStrictEqual(false, arrayBufferViewsLength);
...|
@refack Thanks for your advice! Comments addressed. I have separated the test for |
Looks 💯. Thank you for following up! |
This commit allow passing `TypedArray` and `DataView` to: - v8.deserialize() - new v8.Deserializer() - v8.serializer.writeRawBytes() PR-URL: nodejs#23953 Refs: nodejs#1826 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Refael Ackermann <refack@gmail.com>
|
Landed in 56881b0 🎉 |
This commit allow passing `TypedArray` and `DataView` to: - v8.deserialize() - new v8.Deserializer() - v8.serializer.writeRawBytes() PR-URL: #23953 Refs: #1826 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Refael Ackermann <refack@gmail.com>
This commit allow passing `TypedArray` and `DataView` to: - v8.deserialize() - new v8.Deserializer() - v8.serializer.writeRawBytes() PR-URL: #23953 Refs: #1826 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Refael Ackermann <refack@gmail.com>
This commit allow passing
TypedArrayandDataViewto:v8.deserialize()new v8.Deserializer()v8.serializer.writeRawBytes()Refs: #1826
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passes