withLatestFrom completes with no emissions when input observable has delay
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 31.7k
- Forks
- 3k
- PR merge metrics
- No merged PRs in 30d
Description
Describe the bug
In the code below example$ will complete with no emissions
const source$ = range(1, 3).pipe(
delay(0)
)
const example$ =
range(1, 3).pipe(
withLatestFrom(source$)
)
example$.subscribe(console.log)
Adding observeOn(asyncScheduler) to example$ makes it work as expected
const source$ = range(1, 3).pipe(
delay(0)
)
const example$ =
range(1, 3).pipe(
observeOn(asyncScheduler),
withLatestFrom(source$)
)
example$.subscribe(console.log)
// [ 1, 3 ]
// [ 2, 3 ]
// [ 3, 3 ]
However, bumping the delay to a number above 2 it will make it complete with no emissions again
const source$ = range(1, 3).pipe(
delay(3)
)
const example$ =
range(1, 3).pipe(
observeOn(asyncScheduler),
withLatestFrom(source$)
)
example$.subscribe(console.log)
Expected behavior
When running the code below I expect these emissions after a delay of 300 ms
[ 1, 3 ]
[ 2, 3 ]
[ 3, 3 ]
const source$ = range(1, 3).pipe(
delay(300)
)
const example$ =
range(1, 3).pipe(
withLatestFrom(source$)
)
example$.subscribe(console.log)
Reproduction code
No response
Reproduction URL
https://stackblitz.com/edit/rxjs-se9x2m
Version
7.5.6
Environment
No response
Additional context
No response
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
Start by running the StackBlitz reproduction against RxJS 7.5.6 and trace the withLatestFrom behavior with delay and asyncScheduler. Done means the reported delayed example produces the three expected emissions without requiring observeOn; add or update coverage for the timing cases described in the issue.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100