Description
Problem description
Say I have this little dummy app that is served with bokeh serve ...
:
from bokeh.io import curdoc
from bokeh.layouts import column
from bokeh.models import Div
# Create a simple Div element displaying "Hello World"
hello_world = Div(text="<h1>Hello World</h1>", width=200, height=100)
# Create layout
layout = column(hello_world)
# Add the layout to the current document
curdoc().add_root(layout)
curdoc().title = "Hello World App"
Visiting the app, closing the tab and reopening/restoring it in the browser after the session token has expired simply shows a blank page. The browser console logs include a couple of messages about the websocket connection being lost, e.g. [bokeh 3.6.3] Failed to load Bokeh session PyDgQvf7C2xK4IjiFtOTH6JancEvIOR4nWWcw04ZWwkc: Error: Lost websocket connection, 1005 ()
. The serve logs include this error traceback:
Traceback (most recent call last):
File "/Users/mliquet/dev/panel/.pixi/envs/test-313/lib/python3.13/site-packages/tornado/websocket.py", line 938, in _accept_connection
open_result = handler.open(*handler.open_args, **handler.open_kwargs)
File "/Users/mliquet/dev/panel/.pixi/envs/test-313/lib/python3.13/site-packages/tornado/web.py", line 3302, in wrapper
return method(self, *args, **kwargs)
File "/Users/mliquet/dev/panel/.pixi/envs/test-313/lib/python3.13/site-packages/bokeh/server/views/ws.py", line 149, in open
raise ProtocolError("Token is expired. Configure the app with a larger value for --session-token-expiration if necessary")
bokeh.protocol.exceptions.ProtocolError: Token is expired. Configure the app with a larger value for --session-token-expiration if necessary
As the app visitor, I'm not given much indication about what to do. As the app developer, I see logs that do not indicate explicitly what happened (restored tab).
Feature description
To be honest, I haven't yet given much thought to what could technically be done to improve this situation. As the app visitor, ideally, I'd like my session to be restored or automatically reloaded, at the very least some indication that I should reload the page myself would be welcome. As the app developer, I'd like if the logs could reflect more precisely what happened. The fact that this is raised at the ERROR level is also what brought me here (I'm regularly going through all the errors my app log), in this case I don't think there's much I can do about them except ignore them.
Potential alternatives
TBD
Additional information
No response