clerk
clerk copied to clipboard
Browser UI disappears when exception is thrown
Minimal repro:
Start a deps.edn project:
{:paths ["src"] :deps {io.github.nextjournal/clerk {:mvn/version "0.15.957"}}}
Start a repl and Clerk server, then show!
the following src/repro.clj
file
(ns repro
(:require [nextjournal.clerk :as clerk]
[nextjournal.clerk.viewer :as clerk.v]))
(clerk/with-viewer clerk.v/string-viewer "glub")
;; (throw (ex-info "whoops" {}))
Verify the page at http://localhost:7777/src/repro
is displaying correctly, then uncomment the last line and re-evaluateclerk/show!
Expected outcome:
The error and stacktrace are displayed in red in the browser, which automatically hot-reloads once the exception-throwing expression is resolved (by commenting it out and evaluating clerk/show!
)
Actual:
The browser page turns blank and has to be manually refreshed.
Additional details:
macOS 14.3.1 Clojure 1.11.2 Reproduced on both Firefox (version 123.0.1) and Chrome (Version 104.0.5061.0)
On Firefox, the console prints a series of stack traces from some sort of minified React code:
TypeError: b is null react-dom.production.min.js:183:23
oy Immutable
tna component.cljs:423
Hna template.cljs:128
Ina template.cljs:131
Qna template.cljs:234
qg formatting.cljs:162
$x clojure_mode.cljs:53
pna component.cljs:317
qna component.cljs:364
rna component.cljs:394
aw util.cljs:234
Wla ratom.cljs:337
rna component.cljs:392
c component.cljs:410
React 6
l scheduler.production.min.js:12
Y scheduler.production.min.js:14
93 scheduler.production.min.js:12
zl core.cljs:11933
95 scheduler.production.min.js:20
zl core.cljs:11933
96 React
zl core.cljs:11933
98 React
zl core.cljs:11933
99 React
zl core.cljs:11933
Al core.cljs:12115
<anonymous> parser.cljc:321
The issue appears to happen whenever the file contains a call to clerk/with-viewer
/ clerk/with-viewers
, removing it causes the thrown exception to be displayed in the browser GUI.
Tested with eg. (clerk/with-viewers clerk/default-viewers 123)