sveltejs / sveltejs/kit

Prerendered Remote Function failing on SSR in Cloudflare Workers @sveltejs/adapter-cloudflare

Open
#15,035 3 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

pkg:adapter-cloudflare
Dominant language
JavaScript
Stars
20.8k
Forks
2.3k
Avg merge
1d 16h
Merged PRs (30d)
156

Description

Describe the bug

Prerendered functions don't work with SSR in Cloudflare Workers. When I disable ssr with export const ssr = false, the issue no longer persists.

Reproduction

Repository: https://github.com/alecbakholdin/minimal-cloudflare-remote-fn-test (build files included)
Bug in the wild: https://minimal-cloudflare-remote-fn-test.alecbakholdin.workers.dev

  1. Create a remote function (const testFn = export const testFn = prerender(() => { return "testing"; });)
  2. Call remote function in src/routes/+page.svelte with {await testFn()}
  3. npm run build && npx wrangler deploy
  4. Go to the site and see 500. Logs below
Logs
This is the only relevant log I can find

[500] GET /
Error: Prerendered response not found
    at _worker.js:3303:25
    at async _worker.js:3312:42
    at async _worker.js:3297:18
System Info
System:
    OS: Linux 5.15 Ubuntu 22.04.5 LTS 22.04.5 LTS (Jammy Jellyfish)
    CPU: (24) x64 13th Gen Intel(R) Core(TM) i7-13700K
    Memory: 11.74 GB / 15.47 GB
    Container: Yes
    Shell: 5.1.16 - /bin/bash
  Binaries:
    Node: 20.19.0 - /home/abakholdin/.nvm/versions/node/v20.19.0/bin/node
    npm: 11.6.2 - /home/abakholdin/.nvm/versions/node/v20.19.0/bin/npm
    pnpm: 10.18.2 - /home/abakholdin/.nvm/versions/node/v20.19.0/bin/pnpm
    Deno: 2.5.6 - /home/abakholdin/.local/share/nvim/mason/bin/deno
  npmPackages:
    @sveltejs/adapter-auto: ^7.0.0 => 7.0.0 
    @sveltejs/adapter-cloudflare: ^7.2.4 => 7.2.4 
    @sveltejs/kit: ^2.48.5 => 2.49.1 
    @sveltejs/vite-plugin-svelte: ^6.2.1 => 6.2.1 
    svelte: ^5.43.8 => 5.45.6 
    vite: ^7.2.2 => 7.2.6
Severity

serious, but I can work around it

Additional Information

I can't reproduce this minimally, but on the project where I discovered this bug, sometimes this would work on first page load but not on reloads or afterwards on client-side navigation.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked minimal-cloudflare-remote-fn-test repository and inspect the remote function called from src/routes/+page.svelte. Run npm run build && npx wrangler deploy, then reproduce the 500 response and compare it with the reported “Prerendered response not found” log. Done means the prerendered remote function works during SSR in Cloudflare Workers, including reloads and client-side navigation.

Written by the indexing model from the issue text.

Assessment

Tech stack
cloud, javascript, node.js, vite
Domain
backend, cloud, web-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.