ai newsDi., 1. Dez.

Why our AI app builder kept dying at 128 MB

Originally published at minibuildai.com . Every app built on minibuildai is compiled inside a Cloudflare Durable Object. Durable Objects have a hard 128 MB memory limit. Some of our templates needed more than that to compile — and the way we found out, and fixed it, says something useful about cont

dev.toMontag 09:50 · 30.11.3 Min. Lesezeit
Bild: dev.to

Posted on Nov 30 • Originally published at minibuildai.com

Originally published at minibuildai.com.

Every app built on minibuildai is compiled inside a Cloudflare Durable Object. Durable Objects have a hard 128 MB memory limit. Some of our templates needed more than that to compile — and the way we found out, and fixed it, says something useful about content-addressed caches in general.

minibuildai turns a prompt into a working app and deploys it to Cloudflare. Generated apps come in three shapes: static pages, a small Hono backend with SQLite inside a Durable Object, and login/payments templates that add better-auth, kysely and a payment SDK.

The build runs in the same isolate that serves the workspace. That keeps deploys fast and the architecture simple — until a template needs to install a real dependency tree.

Login-template projects started failing with a single, unhelpful message: "build needs more than the platform's 128 MB memory limit." The apps were tiny. The dependency tree was not. Installing and bundling better-auth plus kysely inside the isolate peaked at roughly 500 MB of heap — the isolate is reset mid-build, and no deployment row is ever written.

If the isolate cannot afford to compile the dependency tree, don't compile it there. We build the login templates' deployment bundle once, offline, outside the 128 MB limit. The artifact (about 1.9 MB of modules) ships next to the template zip.

At deploy time the platform hashes the exact bundler input — every file, the entry points, the asset config. If the hash matches a prebuilt artifact, the deploy copies the modules and skips npm and esbuild entirely. A miss falls back to the slow path, which is correct but cannot survive the memory limit for heavy templates.

For a while everything worked. Then every login-template project started failing again — including, oddly, projects that never changed a file.

The prebuilt cache is keyed by the content hash of the template. Our deploy pipeline regenerates the template archives on every release (prompt files, lockfiles, metadata). The archives changed; the prebuilt artifacts were not rebuilt. Every hash missed. Every deploy fell back to the live install path. Every one of them hit 128 MB.

What made this hard to spot: the fallback is silent by design. A cache miss is a valid state — it means "bundle it live" — so nothing logged a warning, nothing failed loudly. The product just looked like it was broken.

We stopped guessing and ran one clean experiment: create a brand-new project from the untouched login template, deploy immediately, change nothing.

That ruled out accumulated workspace state, a degraded object, and bad generated code. The template itself could not deploy — which could only happen if the prebuilt artifact was never matching.

After the fix, a pristine login-template project deploys in about a second, and the gallery's login app (a real registration-and-database app) builds and ships normally.

A content-addressed cache that silently misses is indistinguishable from a broken product.

If you run a similar pipeline, three habits would have caught this on day one:

128 MB per isolate is a deliberate constraint: it keeps the platform cheap, predictable and fast to start. It is a good limit for serving code and a bad limit for installing arbitrary npm trees. The fix was not to fight the limit — it was to move the expensive, cacheable work outside it and keep the in-isolate path cheap.

If you are building with AI on Cloudflare, the practical rules are the same: prefer no-build output, keep server dependencies small, and treat dependency installation as an offline step.

Two more limits bit us the same month, both worth knowing before you start:

If you want to see what comes out the other end, it is at minibuildai.com — the first two hosted apps are free and a small app costs about $0.08 in credits. But the useful part of this post is the three limits above; they will bite anyone putting a code-generation pipeline on Workers, whatever the product is.

Quelle: dev.to (dev.to). Original öffnen