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

Setting ReactiveVal leads to Unhandled error in some cases #26

Closed
wch opened this issue Jan 19, 2022 · 0 comments · Fixed by #27
Closed

Setting ReactiveVal leads to Unhandled error in some cases #26

wch opened this issue Jan 19, 2022 · 0 comments · Fixed by #27

Comments

@wch
Copy link
Collaborator

wch commented Jan 19, 2022

The following app has a single button, which, when clicked, results in an Unhandled error.

from shiny import *


ui = page_fluid(
    input_action_button("go", "Go"),
)

def server(session: ShinySession):
    v = ReactiveVal(0)

    @reactive()
    def r():
        print("in reactive")
        return v()

    @observe()
    def _():
        session.input["go"]   # Take a dependency on the go button

        with isolate():
            print("in observer 1-1")
            r()
            print("in observer 1-2")
            val = v()
            print("v() is " + str(val))
            print("in observer 1-3")
            v(val + 1)
            print("in observer 1-4")


    @observe()
    def _():
        print("in observer 2-1")
        r()
        print("in observer 2-2")

app = ShinyApp(ui, server)

if __name__ == "__main__":
    app.run()

Before clicking the button, it prints this output:

in observer 1-1
in reactive
in observer 1-2
v() is 0
in observer 1-3
in observer 1-4
in observer 2-1
in reactive
in observer 2-2

When the button is clicked, this output shows up:

in observer 1-1
in observer 1-2
v() is 1
in observer 1-3
Unhandled error: 2763

So the error is happening when v(val + 1) is called.

Almost any change to the structure seems to make the error stop happening. For example, removing the first call to r() makes the error go away.

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 a pull request may close this issue.

1 participant