Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
86fc20c
convex-hosting 0.15.0: serve from the site's files in the pushed code…
nicu-chiciuc Nov 3, 2026
e4b3e7f
Refresh the example patches for routeAll's site argument
nicu-chiciuc Nov 3, 2026
9007184
Review fixes: no redirect for the mark, a large output buffer, no spr…
nicu-chiciuc Nov 3, 2026
59a16b2
Refuse more than 100,000 files, Cloudflare's limit per Worker version
nicu-chiciuc Nov 4, 2026
787b8b6
bench: what one request costs on 0.14.0, this branch, and static-hosting
nicu-chiciuc Nov 4, 2026
4a8fed4
Type the generated site with JSDoc; pass the site in the fixtures' app
nicu-chiciuc Nov 4, 2026
02c093b
bench: a 10,000-file site, and how long its deploy took
nicu-chiciuc Nov 4, 2026
51d6f50
bench: count the calls of the 10,000-file deploy correctly
nicu-chiciuc Nov 4, 2026
b2e0508
Move the benchmark to its own branch, nicu-hosting-bench
nicu-chiciuc Nov 10, 2026
6c2a31c
routeAll takes one object, and version.js exports assets
nicu-chiciuc Nov 10, 2026
6ce0df7
Read the manifest with Cloudflare's own reader
nicu-chiciuc Nov 10, 2026
aeb384a
Mark live from the CLI, keep the storage URLs as one string of keys, …
nicu-chiciuc Nov 10, 2026
592d0e7
Refresh the example patches for routeAll without the component
nicu-chiciuc Nov 10, 2026
ef4a7ae
Find the shared end of the storage URLs without reversing strings
nicu-chiciuc Nov 10, 2026
52dc5b7
Compare the URL ends by index: String.prototype.at is outside the pac…
nicu-chiciuc Nov 10, 2026
6254422
Bring back the mark token; the version file exports only assets
nicu-chiciuc Nov 10, 2026
55f41d6
Run every order of overlapping deploys on the real component and serv…
nicu-chiciuc Nov 10, 2026
2619476
State that the overlap order can also delete a stored file
nicu-chiciuc Nov 10, 2026
ef74582
A mark carries its arrival time, and a late one is refused
nicu-chiciuc Nov 10, 2026
edd691c
Cut a duplicate test, five comments that restate their names, and a s…
nicu-chiciuc Nov 10, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 16 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,14 @@ server build for every other request, as a Cloudflare Worker with static assets
import { httpRouter } from "convex/server";
import { routeAll } from "@samebase/convex-hosting";
import { components } from "./_generated/api.js";
import { versionId } from "../.convex-hosting/version.js";
import { assets } from "../.convex-hosting/version.js";
// Type only, nothing is bundled: the server build imported below.
import type {} from "@samebase/convex-hosting-tanstack-start/server-build";
import server from "../dist/server/server.js";

const http = httpRouter();

routeAll(http, components.hosting, versionId, server);
routeAll({ http, component: components.hosting, assets, worker: server });

export default http;
```
Expand Down Expand Up @@ -106,10 +106,10 @@ wires both.

## Files only

A site without a server leaves the fourth argument out,
`routeAll(http, components.hosting, versionId)`, needs no adapter package, and deploys its build
directory: `--dist dist` after a `vite build`, or `--dist public` with no `--build` at all. A
single-page app adds `--not-found-handling single-page-application`. The
A site without a server leaves `worker` out,
`routeAll({ http, component: components.hosting, assets })`, needs no adapter package, and deploys
its build directory: `--dist dist` after a `vite build`, or `--dist public` with no `--build` at
all. A single-page app adds `--not-found-handling single-page-application`. The
[tanstack-spa](https://github.com/samebase/convex-hosting/tree/main/examples/tanstack-spa) and
[hello-world-assets-only](https://github.com/samebase/convex-hosting/tree/main/examples/hello-world-assets-only)
examples are such sites.
Expand Down Expand Up @@ -161,7 +161,7 @@ inside a Convex HTTP action, so `_headers`, `_redirects`, `.assetsignore`, `html
`not_found_handling` mean what they mean on Cloudflare.

This repository's CI runs Cloudflare's own tests against it: its
[196 cases](https://github.com/samebase/convex-hosting/blob/main/packages/convex-hosting/src/component/conformance.test.ts)
[196 cases](https://github.com/samebase/convex-hosting/blob/main/packages/convex-hosting/src/client/answer.test.ts)
for `html_handling` and path encoding, and its
[integration test](https://github.com/samebase/convex-hosting/tree/main/packages/convex-hosting/src/workers-sdk/fixtures/workers-with-assets-only)
for a files-only site, with its imports pointed at this package, on a local Convex deployment.
Expand All @@ -185,13 +185,15 @@ lists what differs and how to move an app.
On Cloudflare, `wrangler deploy` uploads the files and the Worker code as one version, so the switch
is atomic. Here two systems hold the two halves: the component's storage holds the files, and
`npx convex deploy` pushes the code. `deploy` binds them the same way. It uploads the files as a new
version, writes that version's id to `.convex-hosting/version.js`, and then pushes the code, which
imports the file and asks the component for exactly that version. The push is the switch: no pointer
moves in a second step, so there is no moment when new code serves old files, and no page refers to
a file that is not uploaded yet. The first request the new code serves marks its version live and
deletes the versions that were live before it. A version whose push never came is deleted at a later
switch, once it is a day old; nothing is deleted by the clock alone. The one rule: run one deploy at
a time per deployment. The
version, writes that version's id and its files (each path's stored file, in the layout of
Cloudflare's asset manifest) to `.convex-hosting/version.js`, and then pushes the code, which
imports the file. The push is the switch: no pointer moves in a second step, so there is no moment
when new code serves old files, and no page refers to a file that is not uploaded yet. A request
reads no database: it costs one function call, the HTTP action, and a file adds the download of its
bytes, which Convex counts as a call too. After the push, `deploy` asks the served code to mark its
version live, which deletes the versions that were live before it. A version whose push never came
is deleted at a later switch, once it is a day old; nothing is deleted by the clock alone. The one
rule: run one deploy at a time per deployment. The
[design](https://github.com/samebase/convex-hosting/blob/main/docs/design.md#orderings-and-timing)
works through every interleaving.

Expand Down
21 changes: 12 additions & 9 deletions docs/deploy.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
# Deploy

`deploy` runs `npx convex deploy` with your build and the upload of `--dist` as its `--cmd`. The
pushed code names the version it was built with, so the push switches the site. Then the command
prints the site URL, which it asks the deployment for (`CONVEX_SITE_URL`), and ends. The first
request that the new code serves marks its version live, which deletes the versions that were live
before it. A version that never becomes live, from a deploy that failed, is deleted at the first
switch after it is a day old, and the stored files that no version uses go at the switch after that.
Nothing is deleted while a site gets no request.
pushed code carries the version it was built with and that version's files, so the push switches the
site. Then the command reads the site URL from the deployment (`CONVEX_SITE_URL`), sends one request
to it with the version's mark token, which makes the code that answers mark its version live and
delete the versions that were live before it, prints the site URL, and ends. When that request
fails, the deploy still succeeds and says so; the old versions then stay until the next deploy's
mark. A version that never becomes live, from a deploy that failed, is deleted at the first switch
after it is a day old, and the stored files that no version uses go at the switch after that.
Nothing is deleted but at a deploy's mark.

`deploy` goes to production. `--preview-name <name>` sends it to that preview (with a login or a
project's preview deploy key; always pass the name with that key), and `--dev` to the development
Expand All @@ -15,8 +17,8 @@ deployment (see [Development](./development.md)). A deploy key in `CONVEX_DEPLOY
plain `deploy`, and so does `CONVEX_SELF_HOSTED_URL` for a self-hosted deployment; `--dev` refuses a
key, and `--preview-name` accepts only a preview key, so a production key cannot redirect either.

The first deploy to a deployment pushes the component, then uploads the files. Until that upload
ends, the site answers 404.
The first deploy to a deployment pushes the component, uploads the files, and pushes again. Until
the second push, the site answers 404 naming the version.

Run one deploy at a time per deployment; in GitHub Actions, the job's `concurrency` group queues
them (see [GitHub Actions](#github-actions)).
Expand Down Expand Up @@ -51,7 +53,8 @@ The two handling options work as

Each file of `--dist` must be 25 MiB or smaller, and the CLI names a file that is larger. This is
Cloudflare's limit per asset, and the HTTP action that serves a file cannot answer more than
Convex's 100 MiB response limit anyway.
Convex's 100 MiB response limit anyway. A site has at most 100,000 files, Cloudflare's limit per
Worker version on its Paid plan.

## Deploy tools and CI

Expand Down
Loading
Loading