caolan / caolan/highland

keepAlive option

Open
#266 6 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
3.4k
Forks
145
PR merge metrics
No merged PRs in 30d

Description

Is there away to keep a consuming stream alive even if one of it's feeders sends an end of stream marker?... In my use case I'm dealing with multiple child process stdout streams that will die if the process dies.

for e.g

```
var _ = require("highland");

var mainStr = _().map(function(dat){
return "[prefix] - " + dat;
});
mainStr.pipe(process.stdout);

str1 = _();
str1.pipe(mainStr);
str2 = _();
srt2.pipe(mainStr);

str1.write("here is a message 1");
str2.write("here is a message 2");
str1.write(_.nil);
str2.write("this message will cause an error to be thrown");

// results in error thrown:
// Error: Can not write to stream after nil
```

Is there a way to keep the stream alive, but still clean up after itself when feeders die?
for e.g a `keepAlive` method would be useful.

```
var mainStr = _().keepAlive().map(function(dat){
return "[prefix] - " + dat;
});
```

Contributor guide

Open the contributing guide

Research direction

Start by tracing Highland's handling of _.nil when multiple feeder streams are piped into one consuming stream. Define the intended behavior when one feeder ends, when later feeders write, and when all feeders have ended; then add tests covering the issue's str1/str2 example and cleanup behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
backend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.