[BUG] Bad document JSON data leads to a dangling promise returned by `pull_session`
See original GitHub issueSuppose I have created a document with a non-existing model. When the pull_session
is called, I see these messages in the JS console:
[bokeh] Got an event for unknown model {id: "1053", type: "LinearColorMapper"}
Document.apply_json_patch @ bokeh.js?v=1.3.4:8503
ClientSession._handle_patch @ bokeh.js?v=1.3.4:528
ClientSession.handle @ bokeh.js?v=1.3.4:477
(anonymous) @ bokeh.js?v=1.3.4:317
Promise.then (async)
ClientConnection._repull_session_doc @ bokeh.js?v=1.3.4:299
ClientConnection._awaiting_ack_handler @ bokeh.js?v=1.3.4:405
_current_handler @ bokeh.js?v=1.3.4:347
ClientConnection._on_message @ bokeh.js?v=1.3.4:365
_this.socket.onmessage @ bokeh.js?v=1.3.4:217
21:37:36.553 backend.js:6 Error: event model wasn't known
at Document.apply_json_patch (bokeh.js?v=1.3.4:8504)
at ClientSession._handle_patch (bokeh.js?v=1.3.4:528)
at ClientSession.handle (bokeh.js?v=1.3.4:477)
at bokeh.js?v=1.3.4:317
r @ backend.js:6
(anonymous) @ bokeh.js?v=1.3.4:338
Promise.catch (async)
ClientConnection._repull_session_doc @ bokeh.js?v=1.3.4:336
ClientConnection._awaiting_ack_handler @ bokeh.js?v=1.3.4:405
_current_handler @ bokeh.js?v=1.3.4:347
ClientConnection._on_message @ bokeh.js?v=1.3.4:365
_this.socket.onmessage @ bokeh.js?v=1.3.4:217
21:37:36.553 bokeh.js?v=1.3.4:339 [bokeh] Failed to repull session Error: event model wasn't known
(anonymous) @ bokeh.js?v=1.3.4:339
Promise.catch (async)
ClientConnection._repull_session_doc @ bokeh.js?v=1.3.4:336
ClientConnection._awaiting_ack_handler @ bokeh.js?v=1.3.4:405
_current_handler @ bokeh.js?v=1.3.4:347
ClientConnection._on_message @ bokeh.js?v=1.3.4:365
_this.socket.onmessage @ bokeh.js?v=1.3.4:217
21:40:08.999
It’s pretty clear what the culprit is in my particular case.
However, the issue in Bokeh is that in this case the promise returned by pull_session
is never resolved or rejected. And it makes it seem like add_document_from_session
is still busy.
The root cause, I believe, is that ClientConnection._repull_session_doc
does not call any callback if it fails - it just logs the error and that’s it.
The constructor of ClientConnection
doesn’t even have any such callback for errors not related to a closed connection.
It’s not really related to the issue itself, but there’s also some strange code that:
- Uses both the 2-argument form of
Promise.then
and thePromise.catch
, which makes no sense - Makes it possible to call
reject
afterresolve
has already been called
With that being said, this is probably a very low priority issue since only some specific errors can trigger it, and even then it’s should be clear to the developer what to do. It’s just that the custom error handling code that someone’s app may rely on will never be called.
Issue Analytics
- State:
- Created 4 years ago
- Comments:11 (11 by maintainers)
Top GitHub Comments
This indicates to me that you had a very old setup, so removing the build directory is the only way to go. The new bokehjs’ build uses aggressive caching, which can cause weird behavior in some edge cases, so cleaning up the build (by removing it or running
node make clean
) can help in general, especially after a long absence from bokehjs development.@p-himik we have not made any full promises about BokehJS API compatibility. That’s probably Bokeh 3.0 territory. What we have said is that the range of usage in existing examples in the docs should continue to work. But we have not demonstrated
ClientConnection
in any way, so I’d say it’s fair game (and even to mark as private in some way).