caolan / caolan/highland

Strange behaviour of a forked stream

Open
#614 1 comment 0 reactions 0 assignees View on GitHub
bug
Dominant language
JavaScript
Stars
3.4k
Forks
145
PR merge metrics
No merged PRs in 30d

Description

Check the code below:
```
const H = require('highland')

const IntervalStream = function(time, value) {
return H(function(push, next) {
push(null, value)
setTimeout(
next,
time
)
})
}

const stream = IntervalStream(100, 1).scan1(H.add)
//.tap(x => x)// HACK: doesn't work without tap <-----------------------------

stream.fork().filter(i => i % 5).map(() => '.').pipe(process.stdout)
stream.fork().reject(i => i % 5).map(() => '!').pipe(process.stderr)
```
If run it:
```
>node generator.js
................^C
```
but if I uncoment the line with .tap I see:

```
>node generator.js
....!....!...
```

I believe it's a kind of a bug.
```
"dependencies": {
"highland": "^2.10.5"
}
```

Contributor guide

Open the contributing guide

Research direction

Start by running generator.js with Highland 2.10.5, comparing the forked stream with and without the tap call. Trace how scan1, fork, filter, and reject consume values, then check existing stream tests for related fork behavior. Done means the differing outputs are explained and the intended fork behavior is covered by a regression test.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.