This is basically the same topic as this: Bokeh 2.0 websockets, which has since been closed.
In short, we’ve found its common for our users to leave a Bokeh application idling, come back to it later, and find a dead page. The page is dead because the websocket as been lost, and bokeh fails to reconnect. Yet there is no indication to users that the connection lost, so it’s not immediately clear to them that they should just reload the page.
I would probably intercept all Bokeh log messages and look out for the messages that start with “Lost websocket”.
But It’s not clear to me how to intercept these log messages (a caveat - I’m not a javascript expert).
Here is the log message I think I need to intercept: https://github.com/bokeh/bokeh/blob/branch-3.0/bokehjs/src/lib/client/connection.ts#L213
But from what I can tell, the Logger class stores a reference to logger.info (I’d add a link, but new users can only include 2 links in posts…)
So I can’t simply patch logger.info in a custom javascript callback, since the Logger class already referenced the original logger.info.
Does that make sense?
Is there some other way to intercept these messages? Or perhaps there’s a new, better way to handle lost connections since that topic?
You can see the callback runs and successfully patches console.info. I then force the connection to close, yet there is not “inside the wrapper” message corresponding to the Connection log messages.