question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] Bad document JSON data leads to a dangling promise returned by `pull_session`

See original GitHub issue

Suppose 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:

  1. Uses both the 2-argument form of Promise.then and the Promise.catch, which makes no sense
  2. Makes it possible to call reject after resolve 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:closed
  • Created 4 years ago
  • Comments:11 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
mattpapcommented, Feb 5, 2020

Removing the tree_ts library from the archive.

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.

1reaction
bryevdvcommented, Feb 3, 2020

@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).

Read more comments on GitHub >

github_iconTop Results From Across the Web

javascript - return Promise Pending, and its fullfilled, but not ...
I am calling a local json file using fetch and aync and await, but when I call this all I see in the...
Read more >
Error handling with promises
Let's improve error handling for the user-loading example. The promise returned by fetch rejects when it's impossible to make a request. For instance,...
Read more >
[no-misused-promises] async react callback properties when ...
As you mentioned - this is a correct report as there is a potential bug due to the dangling promise left behind. It's...
Read more >
Resolving the JavaScript Promise Error "TypeError: Cannot ...
This function is expected to return a Promise that should resolve to JSON data. The getGithubOrgs() function is then called with an argument ......
Read more >
Using promises - JavaScript - MDN Web Docs
Essentially, a promise is a returned object to which you attach callbacks, instead of passing callbacks into a function.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found