question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

End streams never seem to end

See original GitHub issue

An 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:open
  • Created 7 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
c-dantecommented, Jun 8, 2016

@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,

var s = stream();
s.end === s.end.end;

Which makes perfect sense – if s.end() === true then we expect s.end.end() === true and so forth, and none of the “is ended” logic fails.

0reactions
StreetStridercommented, Nov 14, 2018

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 from flyd$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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found