Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disabled dangling branches lead to runtime differences in subscription behavior #2007

Open
bruno-f-cruz opened this issue Sep 8, 2024 Discussed in #2006 · 1 comment · May be fixed by #2178
Open

Disabled dangling branches lead to runtime differences in subscription behavior #2007

bruno-f-cruz opened this issue Sep 8, 2024 Discussed in #2006 · 1 comment · May be fixed by #2178
Labels
bug Something isn't working
Milestone

Comments

@bruno-f-cruz
Copy link
Contributor

Discussed in https://github.com/orgs/bonsai-rx/discussions/2006

Originally posted by edmundchong September 8, 2024
I created a frequently updated BehaviorSubject which I pass through some conditional statements. However, there are strange effects from nodes that are commented out (but still connected). Here is a toy example which isolates the issue:

image

In this case mySubject is only initialized once but is propagated 3 times.

When the commented out node is deleted or simply connected on the other end like the rest of the Condition nodes, everything is fine:
image.

The same behavior happens also if I e.g. replace Merge with Zip or CombineLatest or Amb.

Workflow attached below.

foo.bonsai.zip

@bruno-f-cruz bruno-f-cruz changed the title Disabled hanging braches lead to runtime differences in subscription behavior Disabled dangling branches lead to runtime differences in subscription behavior Sep 8, 2024
@glopesdev glopesdev added the bug Something isn't working label Mar 8, 2025
@glopesdev glopesdev added this to the 2.9 milestone Mar 8, 2025
@glopesdev
Copy link
Member

glopesdev commented Mar 8, 2025

@bruno-f-cruz This regression was introduced in #1324 following an optimization whereby unmerged disabled branches can lead to cancellation of multicast behavior:

if (activeBranches == 1) scope.MulticastBuilder.BranchExpression.Cancel();

Unfortunately, the assumptions of the above code are too simplistic (and incorrect). It is quite possible (as your example shows) that the single remaining unmerged branch is in fact a split-and-merge combinator expression which requires the multicast to be preserved for correct behavior.

@glopesdev glopesdev linked a pull request Mar 10, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants