double multicast causes skipping first event
See original GitHub issueHey @briancavalier!
My old vague bug report:
I’ve been chasing down a problem in our app, that seems to be an issue with `multicast`. I’m having a hard time reducing it down to a minimal case and thought I could give you at least a hint, that something is not working as it should.The bug I see is that adding multicast
to a stream subscribed by multiple consumers results in the source stream not emitting the first initial event for some of them. This leads to our app not initialising correctly. Removing multicast
fixes the issue, but since it has multiple consumers it should use it, but not break.
I’ve tried replacing the producer with just
and the issue still occurred. The minimal case I could nail it down to for now is having three consumers where the last one is not receiving the initial event. The one not receiving the event is a combination of combine
and startWith
. Removing startWith
fixes the bug.
Removing one of the other two streams or adding another consumer fixes the bug as well. One of them samples the producer and some other streams. Removing a stream there also fixes the bug.
As you can see it’s hard to find the root cause, since it feels quite arbitrary what causes the issue.
Maybe you already have any idea what the problem might be. I’ll keep trying to reproduce it to a minimal example.
Update: I could boil it down to a minimum:
const most = require('most');
const producer = most.just().multicast();
const working = most.combine(() => 0, producer).multicast();
const broken = most.combine(() => 2, producer).startWith(1);
working.forEach(value => document.write('working: ' + value + '<br>'));
// expected: brokenConsumer should emit 1 and 2
broken.forEach(value => document.write('broken: ' + value + '<br>'));
// removing one of the multicasts fixes the bug
// removing startWith emits 2
Issue Analytics
- State:
- Created 7 years ago
- Comments:6 (2 by maintainers)
Top GitHub Comments
At the risk of unintentionally coming across as one of those smarmy “RTFM” types, I do suggest reading the architecture wiki page, as it’s quite helpful in building an idea of how Most works under the hood. I also suggest perusing some of the code; the design has an elegant but powerful simplicity, and once you understand how it works, you’ll be able to troubleshoot most problems fairly quickly.
I also think it’s an extremely useful exercise to have a go at building a simple producer or combinator. It’s relatively easy, and will help you internalise a much firmer understanding of the library’s inner workings.
Ok thank, will take a look. 👍 Closing this one then.