mergeScan drops accumulator with async merging source
Open
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 31.7k
- Forks
- 3k
- PR merge metrics
- No merged PRs in 30d
Description
Bug Report
Current Behavior
sync
Rx.range(1, 3).pipe(
Rx.mergeScan((acc, n) =>
Rx.of([ ...acc, n ])
, [ 0 ]),
).subscribe(console.log);
// [ 0, 1 ]
// [ 0, 1, 2 ]
// [ 0, 1, 2, 3 ]
async
Rx.range(1, 3).pipe(
Rx.mergeScan((acc, n) =>
Rx.of([ ...acc, n ]).pipe(
Rx.delay(5),
)
, [ 0 ]),
).subscribe(console.log);
// [ 0, 1 ]
// [ 0, 2 ]
// [ 0, 3 ]
Expected behavior
Async accumulating as well as synced one.
Reproduction
Environment
- Runtime: Node v12 v14 v16
- RxJS version: v7.3.0
Possible Solution
Rx.range(1, 3).pipe(
Rx.mergeScan((acc, n) =>
Rx.of([ ...acc, n ]).pipe(
Rx.delay(5),
)
, [ 0 ], 1), // set concurrent to ONE works but loosing parallelism
).subscribe(console.log);
Additional context/Screenshots
#2737
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Run the linked StackBlitz reproduction and compare the synchronous and delayed mergeScan examples. Investigate the mergeScan behavior described in issue #2737, then verify that asynchronous accumulation retains prior values while preserving concurrency greater than one.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- api
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100