-
Notifications
You must be signed in to change notification settings - Fork 141
End asyncStream later in the process (before piping) #185
Conversation
10461d9
to
a1fb334
Compare
Codecov Report
@@ Coverage Diff @@
## master #185 +/- ##
==========================================
+ Coverage 98.28% 98.29% +0.01%
==========================================
Files 14 14
Lines 582 586 +4
Branches 103 104 +1
==========================================
+ Hits 572 576 +4
Misses 10 10
Continue to review full report at Codecov.
|
lib/streams/stringifier-stream.js
Outdated
@@ -22,6 +22,8 @@ module.exports = class StringifierStream extends stream.Transform { | |||
} | |||
let st = this.queue.shift(); | |||
if (st instanceof stream) { | |||
st.emit('plugged'); |
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.
would only emit this if its a instance of async stream though. Totally useless for other fragment streams.
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.
Currently yes, but I didn't want to mix up knowledge of async stream into the stringifier stream
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.
In that case we would need alternative way of handling for this particular instance.
Also could you add a test with the issue so that its easier to track why we moved re-emit it again. |
Sure thing, on it! |
st.end({ | ||
name: 'fragment', | ||
attributes: { | ||
async: true, |
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.
Before, since the fragment's async + also located in handleTag, there would be an error, cause one can't write to async channel after it's ended (which happens on 'finish' events which is all fine, cause we stop writing to the original resultStream right after pushing all parsed chunks).
👍 |
👍 |
Right now asyncStream ends as soon as we stop pushing things to the stringifier stream, which means we can't push things to asyncStream from our customer tags in handleTag.
To support async fragments there we need to end asyncStream later. It seem like proper place would be to end it right before piping it into the resulting stream. I could either do it in the stringifier stream, but though that it'd be better to do via events (
plugged
event).