Yesterday I ran my app with no issues and when I woke up this morning and ran the exact same code I started getting the following error:
ExternalError: TypeError: Right-hand side of ‘instanceof’ is not an object
It always occurs on a line where I am trying to assign the contents of a Plotly figure, and it doesn’t matter what value I’m trying to assign, e.g.:
self.plot_1.figure = None
or
self.plot_1.figure = {}
or
self.plot_1.figure = {'data': ..., 'layout': ...}
What I’m trying to do:
Display a plot
What I’ve tried and what’s not working:
Cloning the app
Creating a copy of the page
Assigning different values to the .figure attribute
Code Sample:
self.plot_1.figure = {}
Clone link:
Unfortunately, I’m not able to share a copy of the app and this behavior is not reproducible in a new app - it works as expected in a new app.
Thank you @stucork! I can confirm that it is working now even without an import anvil.util. I had a sneaking suspicion that it might have something to do with a missing import, but anvil.util was not being explicitly used anywhere in the code. Are there other silently used modules that I should be aware of @stucork ? I have a tendency to remove (seemingly) unused import statements, and I don’t want to end up shooting myself in the foot again.
After more investigation we found that the error would only have occurred for users that didn’t have import plotly.graph_objects as go before using a Plot.
This line gets added whenever you add a plot to the page using the drag and drop designer.
The line can safely be removed if you don’t use the graph_objects module. But that’s why it was missed in our tests.
The graph_objects module imports anvil.util Source code is available at the open source runtime on GitHub.