-
Notifications
You must be signed in to change notification settings - Fork 439
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
refactor: move message handling internals to use async
/await
#1656
base: master
Are you sure you want to change the base?
Conversation
4f03851
to
e761fa1
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1656 +/- ##
==========================================
+ Coverage 78.97% 79.53% +0.56%
==========================================
Files 90 90
Lines 4855 5009 +154
Branches 929 947 +18
==========================================
+ Hits 3834 3984 +150
+ Misses 718 712 -6
- Partials 303 313 +10 ☔ View full report in Codecov by Sentry. |
@MichaelSun90 @mShan0 Mind taking a look? I only moved the |
@@ -48,6 +48,10 @@ | |||
}); | |||
|
|||
afterEach(function(done) { | |||
if (this.timedout) { | |||
console.log({ ...connection, config: undefined }); |
Check failure
Code scanning / CodeQL
Clear-text logging of sensitive information High test
an access to password
This logs sensitive data returned by
an access to password
This logs sensitive data returned by
an access to password
This logs sensitive data returned by
an access to password
This logs sensitive data returned by
an access to password
This logs sensitive data returned by
an access to password
@@ -38,6 +38,10 @@ | |||
}); | |||
|
|||
afterEach(function(done) { | |||
if (this.timedout) { | |||
console.log({ ...connection, config: undefined }); |
Check failure
Code scanning / CodeQL
Clear-text logging of sensitive information High test
an access to password
This logs sensitive data returned by
an access to password
This logs sensitive data returned by
an access to password
This logs sensitive data returned by
an access to password
This logs sensitive data returned by
an access to password
This logs sensitive data returned by
an access to password
@@ -49,6 +50,10 @@ | |||
}); | |||
|
|||
afterEach(function(done) { | |||
if (this.timedout) { | |||
console.log({ ...connection, config: undefined }); |
Check failure
Code scanning / CodeQL
Clear-text logging of sensitive information High test
an access to password
This logs sensitive data returned by
an access to password
This logs sensitive data returned by
an access to password
This logs sensitive data returned by
an access to password
This logs sensitive data returned by
an access to password
This logs sensitive data returned by
This introduces some initial refactoring around
MessageIO
/IncomingMessageStream
/OutgoingMessageStream
.Namely, the goal is to completely remove
IncomingMessageStream
/OutgoingMessageStream
/Message
and replace them with two straightforward functions instead:MessageIO.readMessage
to read the contents of a message as a stream using anAsyncIterable<Buffer>
from aReadable
stream.MessageIO.writeMessage
to write a stream of buffers (generated synchronously via aIterable<Buffer>
or asynchronously via aAsyncIterable<Buffer>
) to aWritable
stream.Both these new methods are much simpler compared to the previous
IncomingMessageStream
/OutgoingMessageStream
implementation, both from a logical complexity as well as an implementation complexity point.They're also both significantly faster than the current implementations. I added benchmarks that try to compare either implementation (benchmarks run using Node.js v18.20.4):
The current implementation spends a lot of time setting up new stream objects for each incoming and outgoing message (via the
Message
class that inherits fromPassThrough
transform stream), and that causes quite a dent in performance, especially when v8 optimizations haven't kicked in yet.