How we moved a 100k-line Deno agent platform to Cloudflare Workers without rewriting
uriwa · reddit · 2026-10-20
The prompt2bot team migrated a 100k-line Deno backend from Deno Deploy to Cloudflare Workers with SQLite-backed Durable Objects — keeping the entire Deno toolchain intact.
Key lessons:
- Kept Deno tests native by stubbing cloudflare:workers (10-line class) in deno.json; a build script re-swaps the stub for the real DurableObject class, shims globalThis.Deno, sets Zod v4 to jitless (Workers blocks new Function).
- 128MB DO heap ceiling: js-tiktoken's BPE ranks expand +43MB, a 275k-word dictionary +35MB, and duplicate pdf.js builds were OOM-killing isolates; stripping static tables at build time freed 80MB.
- Deno KV emulator on DO SQLite: built a drop-in Deno.Kv on a US-East-pinned DO with type-tagged, zero-padded tuple keys so SQLite range queries match Deno KV ordering; atomic check-and-set runs as a synchronous single-threaded transaction.
- 508 Loop Detected: Cloudflare's C++ edge silently copied the inbound cdn-loop: deno header onto outbound fetches, and waitUntil has a hard 30s post-response cap that killed multi-step agent turns.
- Final architecture: one warm Runner Durable Object per conversation, launched via alarm() in a clean IoContext, giving sub-millisecond SQLite state and no queues from 1 to 10k concurrent conversations.
More from coding & agent
- Filling out conference paperwork with Codex: 10 pages done in 7 minutes — vista8 · 2026-10-20
- Hand-migrating a project TypeScript→Flow→TypeScript over nine years, three times — cnakazawa · 2026-10-20
- 「人类必须逐行审代码」已过时:生成与审查都该自动化 — nptacek · 2026-10-20
- NousResearch Hermes agents build Diablo-like RPG with zero asset files, all generated in code — Teknium · 2026-10-20
- Vibe42 turns your home PC into a pocket-access AI coding agent workspace — yihui_indie · 2026-10-20
- Stop button often doesn't stop the LLM: tokens keep generating unless the app hangs up — No-Peanut-6988 · 2026-10-20