sveltejs/kit · error · HandledHttpError
${prerendered.error}
Error message
${prerendered.error} What it means
During prerendering, remote functions first look up a prerendered response cache entry. If that entry is of type 'error', the stored error is re-thrown as a HandledHttpError with the prerendered error's original message, reproducing the failure that was captured when the page was prerendered.
Source
Thrown at packages/kit/src/runtime/app/server/remote/prerender.js:116
/** @type {RemoteFunctionResponse | undefined} */
let prerendered;
try {
// TODO adapters can provide prerendered data more efficiently than
// fetching from the public internet
// `request.url` rather than `event.url`, which throws inside queries
const response = await fetch(new URL(url, event.request.url).href);
if (response.ok) {
prerendered = /** @type {RemoteFunctionResponse} */ (await response.json());
}
} catch {
// not available prerendered, fallback to normal function
}
if (prerendered) {
if (prerendered.type === 'error') {
throw new HandledHttpError(prerendered.error);
}
return parse(prerendered.data)._;
}
}
// during a prerender run, the same function might be invoked while rendering
// multiple pages — share the result across the entire run
if (state.prerendering?.remote_responses.has(url)) {
return /** @type {Promise<any>} */ (state.prerendering.remote_responses.get(url));
}
const promise = run_remote_function(
event,
{ ...state, is_in_remote_prerender: true },
false,
() => validate(arg),
fnView on GitHub (pinned to 03f1687fe6)
Solutions
- Fix the root error the remote function threw during prerendering (check build logs for the original failure)
- Delete the .svelte-kit/build output and re-prerender so the error entry is regenerated
- Guard the remote call with a fallback so it does not fail during prerender
- Ensure required env vars/secrets are available at build time
Example fix
// before: prerendered page captured a failing query
export const load = async () => ({ posts: await getPosts() }); // fails at build if API down
// after
import { prerender } from '$app/server';
export const load = async () => {
try {
return { posts: await getPosts() };
} catch {
return { posts: [] };
}
}; Defensive patterns
Strategy: fallback
Validate before calling
null
Type guard
null
Try / catch
try {
return await myQuery(arg);
} catch (e) {
return fallbackValue; // don't let prerendered error entries propagate
} Prevention
- Make remote functions prerender-safe with try/catch fallbacks
- Always re-prerender after fixing build-time failures
- Verify env vars exist at build time
- Inspect the prerender manifest for error-type entries before deploy
When it happens
Trigger: A remote function is invoked during runtime (or prerender fallback) and finds a prerendered cache entry whose type is 'error' — i.e. the remote call failed when the page was originally prerendered and that failure was serialized into the prerender manifest.
Common situations: Deploying prerendered pages whose remote query/command failed at build time (expired tokens, missing env vars at build); stale .svelte-kit output after an API change; a prerendered page snapshotting an intermittent backend failure.
Related errors
- Cannot call query '${__.name}' while prerendering, as preren
- Cannot call query.batch '${__.name}' while prerendering, as
- Cannot call '${__.name}.withOverride()' on the server
- Cannot access cloudflare:workers in a prerenderable route
- Could not get the request store.
AI-assisted analysis of sveltejs/kit@03f1687fe6 (2026-09-02).
Data as JSON: /api/errors/16e779c4c0371ad2.
Report an issue: GitHub.