SSR / foldkit-ssr
Diagnostics
What SSR meets and keeps going past, a page it contains or a request it
answers 500, is a typed diagnostic, reported through Diagnostics.Reporter
(foldkit-surface's channel, re-exported here), which by default is
Effect's log: the browser's console, or a server's or Worker's log.
_tag | level | When |
|---|---|---|
PageContained | error | The browser contained the page instead of resuming it: reason is NoBuildId, OtherBuild or the ResumeRefused reason |
StaticRegionMissing | error | A static region the browser drew is not in the server's page, so it was rendered in the browser (region) |
BundleUnloaded | error | A lazy bundle's bodies did not load, and the page booted without them (error) |
PageFailed | error | SSR.entry answered 500: headers threw, or the page could not be rendered (url, cause) |
HandlerUnnamed | warning | A handler the page cannot name keeps a page that waits to boot from answering it, once per process |
A page's refusals happen before any runtime starts, so the reporter in its
resources is not in effect yet: SSR.hydrate takes its own. SSR.entry
takes one with the request beside it, used for everything that request runs, a
posted form's Commands included. SSR.generate reports to the reporter in
its Effect's context.
ts
SSR.hydrate(config, plan, { buildId, diagnostics: diagnostic => send(diagnostic) })
SSR.entry(config, plan, {
buildId,
diagnostics: (diagnostic, request) =>
Effect.logError(`${request.method} ${request.url}: ${diagnostic.message}`),
})In a test, Diagnostics.collect() gives a reporter and the array it fills.