-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
Make jest-worker use jest-serializer #5613
Conversation
packages/jest-worker/src/comms.js
Outdated
* saved until there is enough information to parse a payload, then a "message" | ||
* event is emitted. | ||
*/ | ||
export default class extends EventEmitter { |
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.
How about renaming it Communications
? I guess that was the original intent, but shortened.
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.
Comms seems pretty weird, yeah. How about "Channel"?
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.
Done! 🙂
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.
Yeah, now that I read Channel
, I prefer it rather than Communications
. Changing it again 😅
packages/jest-worker/src/channel.js
Outdated
constructor(stream: Duplex) { | ||
super(); | ||
|
||
this._size = Buffer.allocUnsafe(4); |
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.
@mjesun This is v5+ API, so technically we break Node 4 compat :/
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.
Should probably use https://github.com/LinusU/buffer-alloc-unsafe or something, then. Would be great to keep around node 4 support (unofficial though it is) until it's EOL in a couple of months
I'm still investigating how to merge this (if we are going to merge it at all). The internal IPC implementation seems to bypass a bunch of Node layers (e.g. writes directly into the socket via Performance results using The fact that |
TL;DR: Using Command
|
Codecov Report
@@ Coverage Diff @@
## master #5613 +/- ##
==========================================
+ Coverage 63.73% 63.89% +0.16%
==========================================
Files 216 217 +1
Lines 7938 7969 +31
Branches 3 3
==========================================
+ Hits 5059 5092 +33
+ Misses 2878 2876 -2
Partials 1 1
Continue to review full report at Codecov.
|
So what do you wanna do with this PR? |
Ping @mjesun shall we close this for now? |
Yep, let's close it for the moment. A follow up could be to be able to inject the serializer / deserializer; but I'm not going to do that ATM. |
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
This PR implements
jest-serializer
as a new layer for data transmission between the parent process and all the child ones. Since IPC is a custom Node layer, we re-implemented the data transmission as well to work directly with binary buffers, using an extra file descriptor (number4
).The
Comms
class wraps around thefd
Socket
, and provides an almost 1:1 compatible interface withprocess
, providing asend
method and amessage
event. This way, putting theComms
instance was relatively easy.Tests cover all
Comms
class, plus some modification to the originaljest-worker
tests so that they keep passing.