Stop rebuilding the website during wrangler deploy (#410)

## What the log shows

The Cloudflare build for `artcraft-services` succeeded, then failed
during
deploy:

```
04:52:46  Success: Build command completed
04:52:47  Executing user deploy command: npx wrangler deploy
04:52:56  [custom build] Running: npm run build        <-- build runs again
04:53:35  [custom build] Generating static Linux repositories and Flatpak OCI catalog...
04:53:46  [custom build] DOMException [TimeoutError] at fetchHeadPackageSize (linux-repos.ts:274)
          [custom build] Error: Command failed: ... generate-static-repos.mjs
✘ [ERROR] Running custom build `npm run build` failed.
```

Two things combine:

1. The root `wrangler.jsonc` declared `"build": { "command": "npm run
build" }`.
Workers Builds already runs the project's build command, so `wrangler
deploy`
   rebuilt the entire static export a second time.
2. The second pass re-probed every published package on GitHub (523
package
redirects, 19 OCI repos). `fetchHeadPackageSize` treats one 10s HEAD
timeout
   as fatal, so the repeat pass — running ~50s behind the first burst of
   identical requests — failed the deploy.

This is not a regression from #408 or #409: neither touches the website
build.
The `build.command` has been in the config since #354, and the failing
probe is
pre-existing.

## Changes

- `wrangler.jsonc`: remove `build.command`, with a comment explaining
why. The
deploy now uploads the `out/` that Workers Builds just produced,
matching how
the webapp and dashboard Workers already behave. A manual `wrangler
deploy`
  needs `npm run build:website` first.
- `linux-repos.ts`: `fetchHeadPackageSize` retries three times with a
short
  backoff instead of failing the export on a single unanswered HEAD.

## Verification

- `npm ci --ignore-scripts && npm run typecheck` in
  `frontend/apps/artcraft-website-next` — exit 0.
- `wrangler deploy --dry-run --config wrangler.jsonc` against a
placeholder
`out/` parses the config and skips straight to bundling: no `[custom
build]`
pass, which is the behavior this PR is after. The dry-run cannot
complete
locally because `worker/index.mjs` imports `generated-catalog.mjs`,
which the
  full build generates.
- Not run: the Playwright `test:repos` suite, which needs the deployed
preview.

## Risk

- Deploying the website by hand now needs an explicit build first:
  `npm run build:website && npm run deploy:website`. On a clean checkout
`wrangler deploy` fails loudly ("Could not resolve
./generated-catalog.mjs")
because both `out/` and `worker/generated-catalog.mjs` are gitignored
build
  artifacts.
- This assumes the Worker keeps a build command configured in Workers
Builds
(the failing log shows `npm run build`). If that field is cleared, the
deploy
  step has no artifacts to upload.
This commit is contained in:
Dylan M. Taylor authored and GitHub committed 2026-11-18 00:14:37 -05:00
1 parent 590ecaf9b1
commit 999b402564
2 files changed
+30 -12

No files matched your search

@@ -269,18 +269,34 @@ function getAppSection(schemaCategory: string | undefined, slug: string): string
/**
* Reads HTTP HEAD content-length for a package download URL.
*
* A build probes every published package, and GitHub intermittently times out or
* sheds a request under that burst; a single unanswered HEAD used to fail the
* whole static export. Each attempt is therefore retried before giving up.
*/
async function fetchHeadPackageSize(downloadUrl: string, filename: string): Promise<number> {
const headRes = await fetch(downloadUrl, {
method: "HEAD",
redirect: "follow",
signal: AbortSignal.timeout(10_000),
});
const size = Number(headRes.headers.get("content-length"));
if (!headRes.ok || !Number.isSafeInteger(size) || size <= 0) {
throw new Error(`Unable to determine package size for ${filename}`);
const attempts = 3;
let lastError: Error = new Error(`Unable to determine package size for ${filename}`);
for (let attempt = 1; attempt <= attempts; attempt += 1) {
try {
const headRes = await fetch(downloadUrl, {
method: "HEAD",
redirect: "follow",
signal: AbortSignal.timeout(10_000),
});
const size = Number(headRes.headers.get("content-length"));
if (headRes.ok && Number.isSafeInteger(size) && size > 0) {
return size;
}
lastError = new Error(`Unable to determine package size for ${filename}`);
} catch (error) {
lastError = error instanceof Error ? error : lastError;
}
if (attempt < attempts) {
await new Promise((resolve) => setTimeout(resolve, 500 * attempt));
}
}
return size;
throw lastError;
}
type ArchPkgInfo = {
+5 -3
View File
@@ -2,9 +2,11 @@
"name": "artcraft-services",
"compatibility_date": "2026-11-06",
"main": "frontend/apps/artcraft-website-next/worker/index.mjs",
"build": {
"command": "npm run build"
},
// Deliberately no `build.command`: Workers Builds already runs this project's
// build command before the deploy command, and declaring it here made
// `wrangler deploy` rebuild the whole site a second time. That second pass
// repeated every GitHub release probe and failed the deploy on a timeout.
// Deploying by hand therefore needs `npm run build:website` first.
"assets": {
"directory": "./frontend/apps/artcraft-website-next/out",
"binding": "ASSETS",