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

Infinite reactivity issue #352

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft

Infinite reactivity issue #352

wants to merge 2 commits into from

Conversation

JohnCoene
Copy link
Member

Having looked at the issue with infinite reactivity I came up with this quick fix.

Note, as I understand it there are two different cases of the infinite reactivity observed in the app.

  1. Infinite reactivity can happen on almost any input that is not debounced when changed quickly emough, e.g.: numericInput (probably possible on inputs that are debounced but less likely).

The solution here is to capture the last input and check against that server-side. So we run our loop over all fields updating them all, except for the input that triggered that loop of updates. Thereby avoiding the "input updating itself" and leading to an infinite reactive loop.

https://github.com/blockr-org/blockr/blob/1619358e6e6bd32d59511498cb73b6a82689041e/srcjs/input.js#L1

  1. Described in Slider is flickering for filter block  #322 caused by updating generated inputs the list field, namely in the filter. The fix described above does not apply here and we still see the infinite reactive loop.

I can only do this rather ugly hack below to prevent that: if the last input is one of the generated inputs as part of the field we do not update it.

https://github.com/blockr-org/blockr/blob/1619358e6e6bd32d59511498cb73b6a82689041e/R/server.R#L79

Note that I'm really just trying to find a quick fix so we don't encounter that in near-term demos and uses of blockr, I'm well aware that a proper fix is still needed.

@nbenn @DivadNojnarg let me know what you think.

Copy link

codecov bot commented Apr 9, 2024

Codecov Report

Attention: Patch coverage is 76.92308% with 3 lines in your changes are missing coverage. Please review.

Project coverage is 77.61%. Comparing base (6994ab0) to head (4306af6).

Files Patch % Lines
R/server.R 76.92% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #352      +/-   ##
==========================================
- Coverage   77.62%   77.61%   -0.02%     
==========================================
  Files          19       19              
  Lines        2083     2095      +12     
==========================================
+ Hits         1617     1626       +9     
- Misses        466      469       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant