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.

RuntimeError('Cannot apply patch to [id] which is not in the document',) when clicking the Reset button

See original GitHub issue

When I add a figure to a layout after the layout is created, then pan it and reset it, I get the following error (or similar) in the console:

2018-04-03 13:39:59,227 error handling message Message 'PATCH-DOC' (revision 1): RuntimeError('Cannot apply patch to E0EFBC2CAC454F319C97899A5E36FB03 which is not in the document',)
2018-04-03 13:39:59,229 error handling message Message 'PATCH-DOC' (revision 1): RuntimeError('Cannot apply patch to E0EFBC2CAC454F319C97899A5E36FB03 which is not in the document',)
2018-04-03 13:39:59,231 error handling message Message 'PATCH-DOC' (revision 1): RuntimeError('Cannot apply patch to E0EFBC2CAC454F319C97899A5E36FB03 which is not in the document',)

This does not occur if the figure is added to the column on creation (see tan(x) example below).

ALL software version info (bokeh, python, notebook, OS, browser, any other relevant packages)

Windows 10, Python 3.6.4, Bokeh 0.12.15, NumPy 1.14.0, Chrome 65.0.3325.181 (also occurs on Brave 0.22.13).

Description of expected behavior and the observed behavior

Expected behavior: no errors thrown in either the JS console or the terminal.

Observed behavior: figure resets, but errors are thrown.

Complete, minimal, self-contained example code that reproduces the issue

import numpy as np

from bokeh.layouts import column, layout
from bokeh.models import Button
from bokeh.plotting import figure, curdoc

def plot_sin():
	global left_col
	
	if len(left_col.children) == 1:
		p = figure(plot_width=500, plot_height=300)
		x = np.linspace(0, 1, 100)
		p.circle(x, np.sin(2*np.pi*x), color="red")

		left_col.children.append(p)
	
def plot_cos():
	global right_col
	
	if len(right_col.children) == 1:
		p = figure(plot_width=500, plot_height=300)
		x = np.linspace(0, 1, 100)
		p.circle(x, np.cos(2*np.pi*x), color="red")
		
		right_col.children.append(p)
	
doc = curdoc()

sin_button = Button(label="plot sin(x)", width=100, button_type="danger")
sin_button.on_click(plot_sin)

tan_button = Button(label="plot tan(x)", width=100, button_type="success")

cos_button = Button(label="plot cos(x)", width=100, button_type="danger")
cos_button.on_click(plot_cos)

tan_figure = figure(plot_width=500, plot_height=300)
x = np.linspace(0, 1, 100)
tan_figure.circle(x, np.tan(2*np.pi*x), color="green")

left_col = column([sin_button], name="left", width=500)
mid_col = column([tan_button, tan_figure], name="middle", width=500)
right_col = column([cos_button], name="right", width=500)

page = layout(children=[[left_col, mid_col, right_col]])
doc.add_root(page)

Stack traceback and/or browser JavaScript console output

Here’s the JS console output:

session.js:85 [bokeh] Unhandled ERROR reply to 020852938CA94EAC868374171A265F0B: RuntimeError('Cannot apply patch to E0EFBC2CAC454F319C97899A5E36FB03 which is not in the document',)
t._handle_error @ session.js:85
t.handle @ session.js:27
t._steady_state_handler @ connection.js:275
ACK.t.msgtype._current_handler @ connection.js:256
t._on_message @ connection.js:217
t.socket.onmessage @ connection.js:67
session.js:85 [bokeh] Unhandled ERROR reply to 0DDF05BC974D4EBAB148667F0A4E39B6: RuntimeError('Cannot apply patch to E0EFBC2CAC454F319C97899A5E36FB03 which is not in the document',)
t._handle_error @ session.js:85
t.handle @ session.js:27
t._steady_state_handler @ connection.js:275
ACK.t.msgtype._current_handler @ connection.js:256
t._on_message @ connection.js:217
t.socket.onmessage @ connection.js:67
session.js:85 [bokeh] Unhandled ERROR reply to D9118580329C41078B9D18F5D79E7C56: RuntimeError('Cannot apply patch to E0EFBC2CAC454F319C97899A5E36FB03 which is not in the document',)
t._handle_error @ session.js:85
t.handle @ session.js:27
t._steady_state_handler @ connection.js:275
ACK.t.msgtype._current_handler @ connection.js:256
t._on_message @ connection.js:217
t.socket.onmessage @ connection.js:67

Screenshots or screencasts of the bug in action

bokeh-application-google-chrome-4_3_2018-13_48_49

I see similar errors referred to, e.g., #4810 and #4764, but they are marked closed. Is this potentially a regression? I hadn’t noticed this before updating to 0.12.15.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
bryevdvcommented, May 10, 2018

This seems to have been fixed at some point, using the original code I cannot reproduce any errors on current master either in the shell or the js console:

screen shot 2018-05-10 at 12 28 36

If an issue persists please add additional information to reproduce and we can re-open.

0reactions
asartori86commented, Apr 14, 2020

I encountered the same behavior. With these lines, I get the error message

f1 = make_fig1()
f2 = make_fig2()

layout.children[1].children[0] = f1
layout.children[1].children[1] = f2

while if I update the layout as follows the warning disappears

layout.children[1].children[0:2] = [f1,f2]
Read more comments on GitHub >

github_iconTop Results From Across the Web

git: patch does not apply - Stack Overflow
In my case, I got through this problem by removing the entry of the 'file which got removed in the repo' from patch...
Read more >
[Azure IoT Edge]could not read config from /etc/aziot/edged ...
iotedge list; A module runtime error occurred; caused by: Could not list modules; caused by: connection error: Connection reset by peer (os ...
Read more >
Runtime Error: What It Is and How to Fix It - Lifewire
Runtime errors prevent a program from working properly. Here's how to fix runtime errors caused my memory issues, unpatched bugs, and more.
Read more >
8 Ways to Fix the “Class Not Registered” Error on Windows
The “Class Not Registered” error on Windows can be vague, and it's not obvious how you fix it at ... Scroll down and...
Read more >
NetLogo 6.3.0 User Manual: NetLogo Dictionary
If you are not sure how NetLogo will interpret your code, you should add ... all patches turn red ask turtle 4 [...
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