Compare commits

...
1 Commits
Author SHA1 Message Date
Andrey Antukh 2afbbb5cdd 🐛 Fix workspace crash when resolving thumbnail data URIs
The workspace-thumbnail-by-id ref unconditionally called resolve-media
on thumbnail URIs, which caused a stack overflow when the URI was a
data URI (which can be megabytes long for large images).

Data URIs contain thousands of '/' characters (base64 uses '/' as one
of its 64 characters), causing lambdaisland.uri/join to iterate
thousands of times in remove-dot-segments and overflow the JavaScript
call stack.

Add a resolved-uri? helper that checks if the URI already starts with
'blob:' or 'data:', and skip resolve-media for those cases. Only call
resolve-media when the URI is a plain UUID (media-id from the server).

Closes #11562

AI-assisted-by: qwen3.7-plus
2026-09-08 17:10:13 +02:00
+10 -1
View File
@@ -19,6 +19,7 @@
[app.main.store :as st]
[app.main.streams :as ms]
[beicon.v2.core :as rx]
[clojure.string :as str]
[okulary.core :as l]))
;; ---- Global refs
@@ -583,13 +584,21 @@
(dm/get-in state [:viewer-local :zoom-type]))
st/state))
(defn- resolved-uri?
"Returns true if the uri is already a fully resolved URI (blob or data)."
[uri]
(or (str/starts-with? uri "blob:")
(str/starts-with? uri "data:")))
(defn workspace-thumbnail-by-id
[object-id]
(l/derived
(fn [state]
(when-let [entry (dm/get-in state [:thumbnails object-id])]
(cond-> entry
(:uri entry) (update :uri cf/resolve-media))))
(and (:uri entry)
(not (resolved-uri? (:uri entry))))
(update :uri cf/resolve-media))))
st/state))
(def workspace-text-modifier