End streams never seem to end
See original GitHub issueAn end stream never seems to end. This can lead to memory leaks if you need listeners on the end-stream. I have the following code:
appRouter.use('/test/', function(req, resp) {
let resp$ = flyd.stream();
flyd.on(v => { resp.write(v) }, resp$);
flyd.on(v => { resp.end() }, resp$.end);
doAction(resp$);
});
Now doAction can emit as much output it wants to resp$ which is written as a response. At the end it simply emits via resp$.end(true) to end the response. But it seams that the end-stream isn’t closed after it so its handler stays alive which leaks the whole closure (including the resp object for example).
Or is there maybe a way to listen for a stream ending without using ‘on’ on the end-stream?
Issue Analytics
- State:
- Created 7 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
stream wont end : r/Twitch - Reddit
im trying to end my stream for obvious reasons, but whenever i press the 'end stream' button a loading icon appears on it...
Read more >How to close a readable stream (before end)? - Stack Overflow
You can listen to the close event to know exactly when the file is closed. The end event will not fire unless the...
Read more >Twitch Star's 'Never-Ending' Stream Shows No Signs ... - Kotaku
Ludwig Ahgren, a Twitch streamer with nearly 2 million followers, has never been one to shy away from stunts. His latest is especially ......
Read more >Disconnect Protection - Twitch Help
You have 90 seconds to reconnect while the slate appears. If you don't reconnect in that time, your stream will end as normal....
Read more >Do You Love Me? - NEEDY STREAMER OVERLOAD Wiki
KAngel then says that she feels happy and ends the stream with a "BLESS!". During the stream, she seems to be recieving superchat...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@paldepind, I was actually thinking of how to nicely represent end streams (I’ve been tinkering with a stream representation inspired by flyd – trying to figure out what the concerns should be), and my answer to the end stream problem is that you can have it point to itself. Which is almost what’s happening now with it being dependent on the
trueFn
.Really, then, Stream is a recursive type.
So,
Which makes perfect sense – if
s.end() === true
then we expects.end.end() === true
and so forth, and none of the “is ended” logic fails.I’ve noticed that type signature for
end
is different from regular streams (Flow). I believe this is because of end streams have no end. In my typed code sometimes I go away fromflyd$Stream
and use weaker function definition as a stream abstraction.Implementing @c-dante’s idea will lead to filling that gap in typings:
end
stream will be fully fledged stream, because of having of all attributes of regular stream.