Panel app doesn't reconnect on server restart

I’ve upgraded to the latest versions:

bokeh                              3.9.0
panel                              1.8.10

I have

panel.extension(..., reconnect=True)

With this, if I restart the server, I get this in devtool console:

[bokeh 3.9.0] Lost websocket 0 connection, 1006 ()
bokeh.min.js?v=26301…7b17aa1d3699c35:249
[bokeh 3.9.0] Websocket connection 0 is now open
bokeh.min.js?v=26301…7b17aa1d3699c35:249 y: buffer for id=p1067 not found
    at p.error (bokeh.min.js?v=26301…a1d3699c35:214:4858)
    at p._decode_bytes (bokeh.min.js?v=26301…a1d3699c35:214:2843)
    at p._decode (bokeh.min.js?v=26301…a1d3699c35:214:1378)
    at p._decode_ndarray (bokeh.min.js?v=26301…a1d3699c35:214:4109)
    at p._decode (bokeh.min.js?v=26301…a1d3699c35:214:1675)
    at bokeh.min.js?v=26301…a1d3699c35:214:2581
    at d (bokeh.min.js?v=26301…a1d3699c35:179:3764)
    at p._decode_map (bokeh.min.js?v=26301…a1d3699c35:214:2534)
    at p._decode (bokeh.min.js?v=26301…a1d3699c35:214:1339)
    at p._decode_plain_object (bokeh.min.js?v=26301…a1d3699c35:214:2300)
_repull_session_doc	@	bokeh.min.js?v=26301…7b17aa1d3699c35:249
await in _repull_session_doc		
_awaiting_ack_handler	@	bokeh.min.js?v=26301…7b17aa1d3699c35:249
(anonymous)	@	bokeh.min.js?v=26301…7b17aa1d3699c35:249
_on_message	@	bokeh.min.js?v=26301…7b17aa1d3699c35:249
(anonymous)	@	bokeh.min.js?v=26301…7b17aa1d3699c35:249

Similarly, when the session expires, I get this on the python side:

bokeh.protocol.exceptions.ProtocolError: Token is expired. Configure the app with a larger value for --session-token-expiration if necessary

but the backoff just retries and then gives up.

Is there a way to handle this better?

Specifically, is there a way to reload the browser on first reconnect if there’s a failure like the above two cases?

More generally, is there a way to inject custom javascript to receive bokeh websocket events, so that I can plug in my handling as needed? This may be needed to implement a reload backoff (similar to the current websocket reconnect backoff), so reload doesn’t continue indefinitely in case there’s a persistent error.