Skip to content

[Bug]: Bookmark fails when an input read leads to SilentException #2116

@cpsievert

Description

@cpsievert

Component

Session Management

Severity

P0 - Critical (crash/unusable)

Shiny Version

1.5.0

Python Version

Any

Minimal Reproducible Example

from shiny import reactive
from shiny.express import input, ui, app_opts

app_opts(bookmark_store="url")

ui.input_bookmark_button("Do bookmark")

ui.input_slider("slider", "Slider", 0, 100, 50)

@reactive.effect
@reactive.event(input.missing)
def _():
    pass

Behavior

When you click "Do Bookmark", an error notification happens, and no bookmark occurs. A bookmark should occur, and no error should happen.

Image

Error Messages (if any)

Traceback (most recent call last):
  File "/Users/cpsievert/github/py-shiny/shiny/bookmark/_bookmark.py", line 533, in do_bookmark
    full_url = await self.get_bookmark_url()
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/cpsievert/github/py-shiny/shiny/bookmark/_bookmark.py", line 500, in get_bookmark_url
    query_string = await root_state._encode_state()
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/cpsievert/github/py-shiny/shiny/bookmark/_save_state.py", line 116, in _encode_state
    input_values_serialized = await self.input._serialize(
                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/cpsievert/github/py-shiny/shiny/session/_session.py", line 1480, in _serialize
    val = value()
          ^^^^^^^
  File "/Users/cpsievert/github/py-shiny/shiny/reactive/_reactives.py", line 127, in __call__
    return self.get()
           ^^^^^^^^^^
  File "/Users/cpsievert/github/py-shiny/shiny/reactive/_reactives.py", line 149, in get
    raise SilentException
shiny.types.SilentException

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/cpsievert/github/py-shiny/shiny/reactive/_reactives.py", line 584, in _run
    await self._fn()
  File "/Users/cpsievert/github/py-shiny/shiny/reactive/_reactives.py", line 886, in new_user_async_fn
    return await user_fn()
           ^^^^^^^^^^^^^^^
  File "/Users/cpsievert/github/py-shiny/shiny/bookmark/_bookmark.py", line 383, in _
    await root_session.bookmark()
  File "/Users/cpsievert/github/py-shiny/shiny/bookmark/_bookmark.py", line 46, in __call__
    await self.do_bookmark()
  File "/Users/cpsievert/github/py-shiny/shiny/bookmark/_bookmark.py", line 564, in do_bookmark
    raise NotifyException(msg) from e
shiny.types.NotifyException: ('Error bookmarking state: ', True, False)
/Users/cpsievert/github/py-shiny/shiny/reactive/_reactives.py:566: ReactiveWarning: ('Error bookmarking state: ', True, False)
  await self._run()

Environment

N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions