v8: add a js class for Serializer/Dserializer#13541
v8: add a js class for Serializer/Dserializer#13541zimbabao wants to merge 6 commits intonodejs:masterfrom
Conversation
Calling Serializer/Deserlizer without new crashes node. Adding a js class which just inherits cpp bindings. Fixes: nodejs#13326
|
Can you add some regression tests? There were some gotchas around I expect it throws an 'illegal invocation' exception but it would be good to verify that. |
It does, we already extend it :) |
|
I mean when you extend the class that this PR introduces. |
|
@bnoordhuis, the classes this PR introduces are already extended further down the file by |
|
Okay. Regression tests for the other issues would still be good though. |
Calling Serializer/Deserlizer without new crashes node. Adding a js class which just inherits cpp bindings. Fixes: nodejs#13326
|
@bnoordhuis : Added regression tests. |
test/parallel/test-v8-serdes.js
Outdated
| } | ||
|
|
||
| { | ||
| try { |
There was a problem hiding this comment.
Can you use assert.throws() for these.
Calling Serializer/Deserlizer without new crashes node. Adding a js class which just inherits cpp bindings. Added refression tests. Fixes: nodejs#13326
test/parallel/test-v8-serdes.js
Outdated
| v8.Serializer(); | ||
| }, | ||
| Error, | ||
| "Class constructor Serializer cannot be invoked without 'new'" |
There was a problem hiding this comment.
Can you do something more like this:
assert.throws(
() => { v8.Serializer(); },
/^Error: Class constructor Serializer cannot be invoked without 'new'$/
);88817fa to
b72ec9c
Compare
|
There are typos in the commit message(s): s/Dserializer/Deserializer/ |
b72ec9c to
cfb934e
Compare
|
@mscdex : Thanks, fixed |
|
Can somebody fire a CI job for this. |
|
s/refression/regression/ in commit message(s) too. |
Calling Serializer/Deserializer without new crashes node. Adding a js class which just inherits cpp bindings. Added regression tests. Fixes: nodejs#13326
cfb934e to
9643c6c
Compare
|
@mscdex : Fixed on top review. |
lib/v8.js
Outdated
|
|
||
| class Serializer extends serdesBindings.Serializer {} | ||
|
|
||
| class Deserializer extends serdesBindings.Deserializer {} |
There was a problem hiding this comment.
I'd prefer something like:
const { Serializer: _Serializer, Deserializer: _Deserializer } = process.binding('serdes');
// ...
class Serializer extends _Serializer { }
class Deserializer extends _Deserializer { }There was a problem hiding this comment.
@jasnell : Made changes and added a note.
| () => { v8.Deserializer(); }, | ||
| /^TypeError: Class constructor Deserializer cannot be invoked without 'new'$/ | ||
| ); | ||
| } |
There was a problem hiding this comment.
Should likely also add a note to the documentation clarifying the requirement
Calling Serializer/Deserializer without new crashes node. Adding a js class which just inherits cpp bindings. Added regression tests. Fixes: nodejs#13326
47cccbe to
955a1bb
Compare
lib/v8.js
Outdated
| const { Buffer } = require('buffer'); | ||
| const { Serializer, Deserializer } = process.binding('serdes'); | ||
| const { | ||
| Serializer: _Serializer, |
There was a problem hiding this comment.
Can you indent two spaces only?
There was a problem hiding this comment.
Done. BTW jslint didn't catch that error. May be we should add a rule?
Calling Serializer/Deserializer without new crashes node. Adding a js class which just inherits cpp bindings. Added regression tests. Fixes: nodejs#13326
|
Another CI run: https://ci.nodejs.org/job/node-test-pull-request/8588/ |
|
Tests pass on my mac osx sierra laptop. Above failures looks related to CI, can somebody start another run?. |
|
Yea, CI is a bit problematic right now, I’m not sure another run would solve much. This code isn’t platform-specific, though, so I think this is okay. |
|
@addaleax : Thanks, anything else for landing this?. |
|
@zimbabao Our rules say that we’ll need to wait until tomorrow to land this, but nothing from your side I think. :) |
|
arm: #13603 |
|
Landed in 12fd63d, thanks for the PR! |
Calling Serializer/Deserializer without new crashes node. Adding a js class which just inherits cpp bindings. Added regression tests. Fixes: #13326 PR-URL: #13541 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Calling Serializer/Deserializer without new crashes node. Adding a js class which just inherits cpp bindings. Added regression tests. Fixes: #13326 PR-URL: #13541 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Calling Serializer/Deserlizer without new crashes node.
Adding a js class which just inherits cpp bindings.
Fixes: #13326
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passes (test failing on master too)Affected core subsystem(s)