Check component deps before attempting client-side route render

Pages whose components aren't loaded client-side now fall through
to server fetch instead of silently failing in the async callback.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-07 01:13:09 +00:00
parent 59c935e394
commit b90cc59029
2 changed files with 27 additions and 8 deletions

View File

@@ -619,6 +619,16 @@
nil)))
(define deps-satisfied?
(fn (match)
;; Check if all component deps for a page are loaded client-side.
(let ((deps (get match "deps"))
(loaded (loaded-component-names)))
(if (or (nil? deps) (empty? deps))
true
(every? (fn (dep) (contains? loaded dep)) deps)))))
(define try-client-route
(fn (pathname target-sel)
;; Try to render a page client-side. Returns true if successful, false otherwise.
@@ -636,10 +646,12 @@
(let ((target (resolve-route-target target-sel)))
(if (nil? target)
(do (log-warn (str "sx:route target not found: " target-sel)) false)
(do
(log-info (str "sx:route has-data=" (get match "has-data")
" type=" (type-of (get match "has-data"))
" page=" page-name))
(if (not (deps-satisfied? match))
(do (log-info (str "sx:route deps not loaded for " page-name)) false)
(do
(log-info (str "sx:route has-data=" (get match "has-data")
" type=" (type-of (get match "has-data"))
" page=" page-name))
(if (get match "has-data")
;; Data page: check cache, else resolve asynchronously
(let ((cache-key (page-data-cache-key page-name params))
@@ -674,7 +686,7 @@
(do (log-info (str "sx:route server (eval failed) " pathname)) false)
(do
(swap-rendered-content target rendered pathname)
true)))))))))))))
true))))))))))))))
(define bind-client-route-link