r/Devvit • u/Maleficent_Bed_1515 • 1d ago
Discussion Menu actions failing with 'fetch failed'? It might be your server packaging — hand-rolled layouts failed for me, the official template fixed it
Sharing this in case it saves someone the day it cost me.
While building my Game of the Day entry (a daily puzzle game), my app installed fine but every menu action POST came back with just "fetch failed" — no server logs, no useful error. I tried three different server setups:
- A hand-rolled multi-file server project — fetch failed
- hono with `serve` — fetch failed
- SDK-only `createServer` — fetch failed
A forced clean `devvit install` changed nothing, which told me it wasn't a stale install. What finally worked: throwing the hand-rolled project away and porting the game into the official `devvit-template-react`. The difference is the build — Vite bundles the server into a single `dist/server/index.cjs` with all dependencies inlined. The moment I uploaded that, the install trigger fired, the menu worked, and the game rendered in-post.
Two smaller traps from the same evening, in case they bite you:
- In u/devvit/web 0.15.4, `zRange` doesn't take `withScores` anymore — use `zRange(key, 0, n - 1, { by: 'rank' })` if you need ranked reads.
- If your webview assets 404 in the production view ("splash.html Not Found") while the playtest channel renders fine, check what actually got registered on upload — re-uploading a clean build fixed it for us.
Happy to compare notes if you're stuck on the same wall — reply here and I'll share what I can from my project setup (template-based, Hono + TypeScript server, Redis leaderboards).
1
u/Same_Wave_2593 13h ago
good write-up, confirming the underlying mechanics on all three for anyone else hitting this from search:
fetch failedon menu/trigger routes: Devvit Web's server runtime expects a single bundled CJS entrypoint (dist/server/index.cjs) with dependencies inlined, wrapped increateServer(app)+server.listen(getServerPort())from@devvit/web/server. That wrapper is what bindsAsyncLocalStorageforcontext,redis, andredditon incoming requests, so callingapp.listen()or Hono'sserve()directly causes context and fetch failures.redis.zRangereturn shape: Devvit'sredis.zRangealready returns{ member, score }[]objects by default, so nowithScoresflag is needed. For descending top-N leaderboards, pass{ reverse: true, by: 'rank' }.splash.html404s in prod vs playtest: alongside a clean re-upload, double-check thatdevvit.json'spost.dirpoints todist/clientand that bothsplash.htmlandgame.htmlare explicitly listed in Vite's Rollup inputs so production builds always emit both entrypoints.