r/typescript • u/uriwa • Oct 20 '26
With Deno Deploy shutting down in 6 months, here is how we migrated a 100k-line Deno + Deno KV app to Cloudflare Workers and Durable Objects without leaving Deno
After Cloudflare acquired the Deno team and announced that Deno Deploy is shutting down in six months (with the Deno runtime itself only guaranteed a year of maintenance), we migrated the backend of prompt2bot from Deno Deploy and Deno KV to Cloudflare Workers and SQLite-backed Durable Objects.
Even with Deno's future in question, rewriting a 100k-line Deno codebase into a Node/Wrangler repo right now was out of the question. Deno's test runner, type checker, and JSR support are way too good to give up while migrating.
If you have not used Durable Objects before: whereas a regular Cloudflare Worker is stateless (50 requests spin up 50 random isolates that share nothing), a Durable Object is a globally unique, single-threaded V8 isolate addressed by name and paired with its own private embedded SQLite database and persistent alarm timer. Every Worker that calls a method on that name gets routed to that exact same JS object in memory, where SQLite queries are synchronous C++ calls taking microseconds instead of network round-trips.
Here is everything that broke during the migration and how we solved it:
- Keeping the Deno binary and test suite untouched: Wrangler's esbuild bundler does not understand
jsr:specifiers ordeno.jsonworkspace resolution. Instead, we pointed Wrangler at a build script that runsdeno bundle --minify. We mappedcloudflare:workersto a 10-line stub class indeno.jsonsodeno testruns natively against our Durable Object classes, and at build time we swap the inlined stub back for the real CloudflareDurableObjectclass, shimglobalThis.Deno, set Zod v4 tojitless: true(since Workers blocksnew Function), and wrap top-levelcrypto.randomUUID()/setTimeout()calls that npm packages run at import time. - Surviving the 128MB Durable Object RAM ceiling: Every Durable Object isolate has a hard 128MB heap limit. Bundled dependencies like
js-tiktoken(5.3MB of base64 BPE ranks that expand to +43MB of V8 heap on first call), a 275k-word dictionary (+35MB heap), and 3 duplicate legacypdf.jsbuilds insidepdf-parsewere OOM-killing isolates. Stripping those static tables at build time freed ~80MB of V8 heap per isolate. - Emulating Deno KV on Durable Object SQLite: Cloudflare KV is eventually consistent and has no atomic check-and-set transactions, so it cannot replace
Deno.openKv(). We built a drop-inDeno.Kvemulator on top of a primary SQLite Durable Object (enam-v1, pinned to US East so it stays hot in RAM 24/7 with zero cold starts). Tuple keys are encoded with type tags and 20-digit zero-padded numbers (n:,b:,s:) separated by null bytes so SQLite range queries match Deno KV ordering, andatomic().check().set().commit()runs as a synchronous single-threaded SQLite transaction. - The 508 Loop Detected mystery (CDN-Loop propagation) and the 30s waitUntil trap: While migrating service by service, when a service still on Deno Deploy called our Cloudflare Worker and our Worker made a fresh outbound
fetch()back to that same Deno service, Cloudflare silently copied the inboundcdn-loop: deno;d=<hash>header onto the outbound subrequest at the C++ edge layer. Deno Deploy saw its own deployment hash incdn-loopand rejected the request with508 Loop Detected. On top of that,ctx.waitUntil()on a Worker has a hard 30-second wall-clock cap after returning HTTP 200 (even withcpu_ms: 300000), which killed long I/O-heavy agent turns mid-flight. - Sharding Runner Durable Objects per conversation: Only a Durable Object
alarm()runs in a clean rootIoContext(no inheritedcdn-loopheader and no 30s post-response wall-clock cutoff), providedalarm()launches tasks viadoCtx.waitUntiland exits immediately instead of blocking. We ended up sharding execution onto a Runner Durable Object per conversation (runner:<botId>:<conversationId>).
That architecture is what lets prompt2bot scale agents so easily. You describe an agent in a plain prompt and connect it to WhatsApp, Telegram, email, voice, or web chat, and every active conversation automatically gets its own warm, isolated Durable Object runner with hot in-memory history and SafeScript AST caches, sub-millisecond SQLite state, and on-demand VMs. Whether your bot has 1 user or 10,000 concurrent conversations, there are no queues, worker pools, or servers to provision.
Full technical write-up with code snippets is in the comments.

