Site administration
Object storage on Neon
Source keeps the files that are not git and not rows in Neon object storage: LFS objects, assets, avatars, transcripts, the agent audit, large vault files, the CI cache, the logs, results and artifacts of CI jobs, the checkpoints and bundles of the factory, and the files of artifact pages. Neon object storage is in AWS us-east-1, next to Postgres and the web Worker. Measured on 2026-11-27 from a Worker placed where the web Worker runs, a small read took 44 ms on Neon and 128 ms on R2, and a small write 79 ms on Neon and 446 ms on R2. It keeps every file. Copies of the LFS objects and assets in Europe and Asia serve the downloads of the clients near them (Serve LFS files and assets from Europe and Asia), and the app reads Neon in us-east-1 for everything else. R2 keeps a backup copy of what people and apps add: LFS objects, assets, the agent audit, avatars, transcripts, app card files and large vault files (The R2 backup). This page sets it up, checks it, and says what happens when Neon fails.
12 min read
You need:
neonctl, signed in to the TanStack organization on Neon.- Wrangler, signed in to the Cloudflare account of the forge, run from
apps/web.
1. Make the storage project
The Neon project source-objects (late-paper-15050690, AWS us-east-1) has been in place since 2026-11-27, with three private buckets on its main branch: artifacts, lfs and vault. It is a project of its own, so no key of it can reach the database branches of the project source.
To make it again:
neonctl projects create --org-id org-green-water-28502066 --name source-objects --region-id aws-us-east-1 --no-secrets
neonctl buckets create artifacts --project-id <project id> --branch main
neonctl buckets create lfs --project-id <project id> --branch main
neonctl buckets create vault --project-id <project id> --branch main
Neon makes a "Default object storage credential" with every new project, which can read and write every bucket. Revoke it once your own keys are made (step 2): neonctl credentials list and neonctl credentials revoke <id>. Neon also keeps a "Default AI gateway credential", and makes it again when you revoke it. It can't read storage.
Don't use neonctl env pull on this project: it makes the default storage key again.
2. Give the keys Worker its keys
Only the keys Worker holds the storage keys. It signs each request of the web and runner Workers (signStorage in apps/web/src/keys.ts), so no storage key is in those Workers. Neon allows each key 600 requests a second and 24,000 a minute, and answers 503 SlowDown over either. The keys Worker picks a key at random for each request, so 32 keys take about 12,800 requests a second for a whole minute, and up to about 19,200 in a burst. The keys Worker takes at most 64.
Make 32 keys and put them straight into the secret NEON_STORAGE_KEYS, a JSON array of { "id", "secret" }. Nothing is printed and nothing is saved in a file:
python3 -c '
import json, subprocess
keys = []
for n in range(1, 33):
made = json.loads(subprocess.check_output(["neonctl", "credentials", "create", "--project-id", "late-paper-15050690", "--branch", "main", "--name", f"source-objects-{n}", "--scope", "storage:read", "--scope", "storage:write", "--output", "json"], stderr=subprocess.DEVNULL))
keys.append({"id": made["token_id"], "secret": made["s3_secret_access_key"]})
print(json.dumps(keys))
' | pnpm exec wrangler versions secret put NEON_STORAGE_KEYS -c wrangler.keys.jsonc --tag storage-keys --message "Neon object storage keys"
pnpm exec wrangler versions deploy <the version id it printed>@100% -c wrangler.keys.jsonc
The new version has a tag, so the next ci/deploy goes on as usual (README.md, "Deploying"). The endpoint and the region are vars of the keys Worker (NEON_STORAGE_ENDPOINT and NEON_STORAGE_REGION in wrangler.keys.jsonc). Without the keys, every read and write of object storage fails.
To rotate, make new keys the same way, deploy the version, then revoke the old keys with neonctl credentials revoke.
3. Check that it works
- Upload an image to the Assets tab of a test repository.
- Look for it in Neon:
neonctl buckets object list lfs/assets/<repository id>/ --project-id late-paper-15050690 --branch main. - Start a CI run. The logs of its jobs are in Neon:
neonctl buckets object list artifacts/logs/<job id>/ --recursive --project-id late-paper-15050690 --branch main.
Done
Every file that Source keeps outside git and Postgres is in Neon object storage, next to the web Worker and Postgres, and R2 keeps a backup copy of what people and apps add.
When Neon fails
Neon object storage is the only store that the app reads. While it fails, these fail too: LFS downloads and uploads, assets, avatars, transcripts, large vault files, CI logs, results and artifacts, CI cache restores and saves, artifact pages, and the saves and restores of factory checkpoints. Each failed request fails its call, and Sentry gets the error. No other store answers, so nothing needs to change back when Neon recovers. A CI cache save that fails leaves no entry, and the job goes on. The R2 backup answers no read: it is there to restore what people and apps added if Neon loses it (The R2 backup).
How it works
objectStore(name) (apps/web/src/server/storage/index.ts) gives the Neon bucket artifacts, lfs or vault, with the API of the R2 binding (apps/web/src/server/storage/neon.ts). The tests have no Neon: there, it gives the fake bucket that a test puts in env.
| Bucket | Keys |
|---|---|
lfs | LFS objects (objects/), assets (assets/), the agent audit (audit/), the temporary keys of an upload being checked (tmp/), the packs of pushes in parts (maintenance/) |
artifacts | avatars (avatars/), transcripts (transcripts/), CI artifacts, surface files and app card files (artifacts/), large CI plans and the results, step reports and fixups of CI jobs (ci/), the logs of CI jobs and of src job run (logs/), the patches of suggestions (suggestions/) and of factory runs (factory/), the bundles of factory files and agent workflows (factory-bundles/), the CI cache (cache/<repo id>/), the checkpoints of the factory (factory-checkpoints/<repo id>/), the records of the PR chat (pr-chat/<repo id>/), the files of artifact pages (artifact-pages/) and the temporary keys of their uploads (artifact-tmp/), and the analytics batches that never got into ClickHouse (analytics-dead/) |
vault | the ciphertexts of vault files over 64 KiB (vault/<repo id>/) |
The sandbox of a factory run gets the artifacts bucket as its binding CHECKPOINTS, and the checkpoint host writes the checkpoints of a run on a Ravion VM. The purge of a deleted repository deletes every prefix of the repository in the three buckets, and its copies in the R2 backup (apps/web/src/server/repo-purge.ts). The nightly ClickHouse backups are in a Neon project of their own (Back up the analytics database).
A CI log chunk names its lines in its key, logs/<job id>/steps/<step>/<chunk index>.<first line>.<lines>, because an S3 list gives no custom metadata. A job keeps its log region in its record. It said where the job's data was while R2 kept some of it, and no reader looks at it now.
Neon keeps lifecycle rules but does not run them. So the daily cron deletes the staging keys older than a day (tmp/ in lfs and artifact-tmp/ in artifacts) and aborts the multipart uploads older than 7 days (storage leftovers, apps/web/src/server/storage/leftovers.ts). Every request is timed as fetch neon <operation> in analytics.timings (docs/admin/timings.md).
The R2 backup
R2 keeps a copy of what people and apps add: the keys of BACKUP_RULES in apps/web/src/server/storage/backup.ts.
| R2 bucket | Keys |
|---|---|
gitflare-lfs | LFS objects (objects/), assets (assets/), the agent audit (audit/) |
gitflare-artifacts | avatars (avatars/), transcripts (transcripts/), app card files (artifacts/ci/<repo id>/apps/) |
gitflare-vault | the ciphertexts of vault files over 64 KiB (vault/<repo id>/) |
The web and runner Workers bind these three buckets as ARTIFACTS, LFS and VAULT, and only objectStore uses them (withBackup):
- After a write of such a key in Neon (a put, or an upload in parts that completes), a copy goes to R2 after the answer (
backupToR2). A copy that fails logs a warning, and the reconcile copies it. - A delete of such a key deletes its copy in R2 too, before it answers, so the audit retention and every other delete reach the backup. The purge of a deleted repository also lists the backup itself, so a copy whose delete failed goes too.
- The app never reads R2: each read and list asks Neon alone.
Each day at 03:07 UTC, the daily work of the web cron runs the task storage reconcile (reconcileStep). For each prefix above, it compares the keys and sizes of Neon and R2, and copies what R2 lacks, at most 50,000 files, 20 GiB and 2 minutes a day. Workers Logs show a line with diag = "storage reconcile": the keys that it checked (checked) and copied (copied), and the keys that only R2 has (onlyInR2). It leaves those for an operator to look at: such a key is a sign of a delete that failed in R2.
To restore a file that Neon lost, copy it from its R2 bucket to the same key in Neon, with its content type and custom metadata.
Cloudflare's cache in front of Neon
From a Worker, a request to Neon's endpoint passes through Cloudflare's cache (its answers carry server: cloudflare and cf-cache-status). For a key whose extension Cloudflare caches by default, such as .tar.zst, .zip or .js, the cache sends a HEAD on to Neon as a GET, and a read without its Range. The request no longer matches its signature, and Neon answers 403 (SignatureDoesNotMatch). So the Neon client (apps/web/src/server/storage/neon.ts) sends every request with cache: 'no-store', which the cache leaves as it is.
From 2026-11-30 22:15 to the deploy of this fix, the HEAD after the complete of every factory checkpoint (.tar.zst) got 403, so every checkpoint save failed (Sentry SOURCE-WORKER-A9). A probe from a Worker on 2026-12-01 showed it for keys ending in .zst, .tar.zst and .bin, and not for keys with no extension or .json, whatever their content type and metadata. A request from outside Cloudflare reaches Neon directly and never sees it. When the complete of a checkpoint's upload fails, the checkpoint gateway now deletes the object, so no checkpoint object stays without a record (apps/web/src/server/factory/checkpoint-gateway.ts).
A read right after a write
Neon documents no order of a read after a write: its pages say nothing about it. On 2026-12-01 a HEAD right after a put that Neon took answered 404 twice, for two CI cache entries, while the objects were there with the time of the put (Sentry SOURCE-WORKER-AJ). So a writer that knows the length of its stream states it (sizedStream, which writeSized in apps/web/src/server/jobs/parted-upload.ts uses), and the put answers from the put alone. A put of a stream whose length only Neon knows reads the size with a HEAD after it, and asks again after 100 ms, 400 ms and 1.5 s before it fails.
The size of one request
A Worker or a Durable Object sends Neon a request body of at most 100 MiB (104,857,600 bytes). Cloudflare refuses a longer one, and the Maximum Upload Size of the zone does not raise this limit. It is not a limit of Neon's: Neon took a put of 512 MiB from outside Cloudflare, and its documents allow 5 GiB in one put. On 2026-11-30 a put of 497 MiB from the web Worker failed with 413 and no S3 error. On 2026-12-01 a probe from a Worker sent 104,857,600 bytes in one put, and in one part of a multipart upload, and both went through. One byte more failed at once, for both. Cloudflare documents the same 100 MiB for Durable Objects and Containers.
So every write that can be longer goes in parts of a multipart upload:
| Write | Parts |
|---|---|
| A CI cache entry or a CI artifact that a job sends in one request | 10 MiB, for an entry over 100 MiB, and for every artifact |
| A CI cache entry, a CI artifact or a factory checkpoint that the runner agent sends in parts | The agent's parts, of at most 64 MiB |
| A checkpoint of a factory run in a Cloudflare container (the sandbox's backup, through its gateway) | 16 MiB, which the sandbox sets |
| An LFS object or an asset over 100 MiB, which only a higher site limit lets in | 10 MiB |
| A push in parts | At most 100 MiB, whatever the push request limit |
The Neon client (NEON_REQUEST_MAX_BYTES in apps/web/src/server/storage/neon.ts) refuses a put or a part that it knows is longer, before it sends it, with the code RequestTooLarge.
Local development
pnpm dev starts a stand-in of Neon object storage (apps/web/scripts/dev-neon.ts): the in-memory S3 server of the tests (apps/web/test/support/s3.ts), served over http on 127.0.0.1:8421. Its files are in apps/web/.wrangler/state/neon, so they stay from one run to the next. The keys Worker of the dev server signs the requests of the other Workers for it, with a key of that run only. It accepts an endpoint over http on the loopback only, and https everywhere else.
DEV_NEON_PORTsets another port. In asrc wsworkspace, it takes the fourth port of the workspace (SRC_WS_PORT_3).DEV_NEON=0starts none. Then each read and write of object storage fails, as it does in a plainvite dev.
Before Neon
R2 kept these files before. The move went in stages: new writes to Neon, then a copy of the older files that pages read, then the removal of the R2 bindings, all but the three of the backup. The copy took the results, plans, artifacts, patches, bundles and logs of CI and the factory, the CI logs of the R2 buckets of the regions, the checkpoints of the 30 days before it, and the backup gitflare-lfs/backups/TanStack/modelschemas/. It gave each CI log chunk its Neon name, and copied the step states of the CI logs from before 2026-11-11 (logs/<job id>/steps/<step>.state) with their metadata. It took no CI cache entry, no PR chat record, no analytics dead letter and no other backup. A CI cache entry whose bytes stayed in R2 is dropped by the first restore that finds it, which then searches on.
The exit copy used eight slices and limited their Neon requests to avoid SlowDown responses. It listed existing Neon objects before copying, retried slowed puts, and limited large copies and request times. These safeguards applied to the removed copy, not to current writes.