Skip to content

reinitialize vis to avoid mysterious errors - #36

Merged
dobbs merged 5 commits into
mainfrom
mysterious
Jan 17, 2026
Merged

reinitialize vis to avoid mysterious errors#36
dobbs merged 5 commits into
mainfrom
mysterious

Conversation

@WardCunningham

@WardCunningham WardCunningham commented Dec 1, 2025

Copy link
Copy Markdown
Member

Nick and I tried moving one line around and it seems to behave much better in my Solo generated test case.

This is a work in progress.

@WardCunningham
WardCunningham requested a review from dobbs December 1, 2025 19:06
@WardCunningham

Copy link
Copy Markdown
Member Author

This observation was from our joint investigation last Saturday.

I have found two ways to refresh this page, one that always works and one that rarely works.
http://ward.dojo.fed.wiki/view/patterns-on-wiki-1996
° Reloading the browser tab always works.
° Jiggling the page to induce a redraw rarely works.
My pet theory now is that we're hanging on to viz that is exhausting something that eventually gets restored to make it work occasionally. Perhaps emit needs to reconstruct something that is currently being preserved through multiple calls to emit/bind.

@dobbs

dobbs commented Dec 2, 2025

Copy link
Copy Markdown
Member

I looked back at some old commits:
4873d39 I removed the <graphviz-viewer> custom element and switched from HPCC's graphviz back to viz.js.
9fd97ab I switched to a dynamic import() to fix the tests and also created initializeDraw().
#29 (comment) I specifically compared with Observable.

That prompted me to discover that Bostock found and fixed a related problem in 2018!
observablehq/graphviz#3

As such, I think we might use a similar approach here. Wrap the call to viz.renderSVGElement(dot) in a try...catch that re-initializes the viz object.

@dobbs

dobbs commented Dec 7, 2025

Copy link
Copy Markdown
Member

On closer inspection the current Observable Framework is using this code to render graphviz with a static import and a global const:
https://github.com/observablehq/framework/blob/5745573b5ccaff92e837d692e9c559993f684d28/src/client/stdlib/dot.js

It no longer has a try...catch wrapped around the renderSVGElement() call. I wonder if upgrading would be sufficient.

@dobbs

dobbs commented Dec 8, 2025

Copy link
Copy Markdown
Member

I still do not understand the mechanism of failure. However Thompson's test case seems to work with this update to a newer Graphviz.
http://wiki.dbbs.co/view/welcome-visitors/thompson.genius.ustawi.wiki/deep-truth-pattern

@dobbs
dobbs merged commit dad10f9 into main Jan 17, 2026
@dobbs
dobbs deleted the mysterious branch January 17, 2026 02:00
@dobbs

dobbs commented Jan 17, 2026

Copy link
Copy Markdown
Member

Decided this has been working long enough that we could promote it to an official release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants