caolan / caolan/highland

Dynamic forking: inconsistent behavior

Open
#638 4 comments 0 reactions 0 assignees View on GitHub
3.x bug
Dominant language
JavaScript
Stars
3.4k
Forks
145
PR merge metrics
No merged PRs in 30d

Description

### Environment

Highland: 3.0.0.beta-5
Browser: Chrome 61

### Example
```es6
const numbers = Stream();
const even = numbers.fork().filter(x => x % 2 === 0);
const odd = numbers.fork().filter(x => x % 2 !== 0);

even.each((x) => { console.log("even", x); });
odd.fork().each((x) => { console.log("odd", x); });

numbers.write(1);
numbers.write(2);

console.log("> five is added");
const five = odd.fork().filter(x => x === 5);

console.log("> late write");
numbers.write(4);
numbers.write(3);

console.log("> late write 2");
numbers.write(6);
numbers.write(5);

console.log("> consume five");
five.each((x) => { console.log("five", x); })
```

The output:
```
odd 1
even 2
> five is added
> late write
even 4
> late write 2
> consume five
odd 3
even 6
odd 5
five 5
```

### Problem
During "late write" step `even` path is getting processed, while on "late write 2" step it is paused.
This is inconsistent as it should be either paused from the beginning or getting processed all the time (which in my opinion is an option that grants a broader set of capabilities).

Contributor guide

Open the contributing guide

Research direction

Reproduce the reported example with Highland 3.0.0.beta-5 and compare the two late-write stages. Then trace the dynamic fork and stream-consumption entry points to determine why the path pauses inconsistently, and add a regression test that captures the agreed behavior. The issue does not name source files or an existing test.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
stream-processing
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.