Skip to content

Updating express inputs leads to an error #1034

@cpsievert

Description

@cpsievert

Consider the following app, which from a user perspective is functional, but does generate an error (since the 1st time it runs a session hasn't been established):

from shiny import reactive
from shiny.express import ui

ui.input_slider("n", "N", 1, 100, 50)

@reactive.effect
def _():
    ui.update_slider("n", value=10)
Traceback (most recent call last):
  File "/Users/cpsievert/github/py-shiny/shiny/reactive/_reactives.py", line 573, in _run
    await self._fn()
  File "/Users/cpsievert/github/py-shiny/shiny/_utils.py", line 243, in fn_async
    return fn(*args, **kwargs)
  File "/Users/cpsievert/github/py-shiny/sandbox/app.py", line 8, in _
    ui.update_slider("n", value=10)
  File "/Users/cpsievert/github/py-shiny/shiny/ui/_input_update.py", line 780, in update_slider
    session = require_active_session(session)
  File "/Users/cpsievert/github/py-shiny/shiny/session/_utils.py", line 127, in require_active_session
    raise RuntimeError(
RuntimeError: update_slider() must be called from within an active Shiny session.
/Users/cpsievert/github/py-shiny/shiny/reactive/_reactives.py:555: ReactiveWarning: Error in Effect: update_slider() must be called from within an active Shiny session.
  await self._run()

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions