Skip to content

id(web/build-manifest): a second run deletes the only stylesheet and drops its manifest entry — dist is left unstyled, exit 0 #6969

Closed

Description

@dezren39

Problem

pkgs/id/web/scripts/build-manifest.ts is not idempotent: a second run deletes the web UI's only stylesheet and writes a manifest that no longer mentions it — exit 0, no warning.

The script's first step deletes every hashed stylesheet in dist/:

// Remove stale hashed CSS files before processing
for (const file of readdirSync(distDir)) {
  if (file.match(/^styles\.[a-f0-9]+\.css$/)) {
    unlinkSync(join(distDir, file));
  }
}

The only path that puts a stylesheet back is renaming an unhashed styles.css (the Tailwind output) later in the script. After a first run, dist/ contains only styles.<hash>.css — there is no styles.css left to rename. So a second run:

  1. deletes styles.<hash>.css (the live stylesheet),
  2. finds no styles.css to rename,
  3. writes manifest.json with no styles.css entry, and logs it as success.

The Rust server then silently falls back to the unhashed default URL (pkgs/id/src/web/mod.rs, load_asset_urls: missing styles.css key → /assets/styles.css), which does not exist in dist/ — every page is served unstyled, with no error at build time or runtime.

build:manifest is a standalone script in pkgs/id/web/package.json ("build:manifest": "bun run scripts/build-manifest.ts"), so re-running it on an already-built dist/ — a rebuild retry, a packaging step, a developer re-running one stage — is a realistic invocation, not a contrived one. The full bun run build sequence masks the bug because build:css regenerates styles.css first.

Evidence (verified this run, laptop probe)

Fixture dist/ with styles.css + main.abc12xyz.js, script copied verbatim from pkgs/id/web/scripts/build-manifest.ts @ main d3c26e14b5, probe at ~/git/fleet/probe-build-manifest on the laptop:

  • Run 1: manifest.json: { "main.js": "main.abc12xyz.js", "styles.css": "styles.74d94aed.css" }; dist/ = main.abc12xyz.js, manifest.json, styles.74d94aed.css. Correct.
  • Run 2 (same dist, no regeneration): manifest.json: { "main.js": "main.abc12xyz.js" }; dist/ = main.abc12xyz.js, manifest.json — styles.74d94aed.css is gone and the manifest has no styles.css entry. Exit code 0.

The JS side does not have this defect: the hashed bundle is kept and re-recorded on re-runs (only stale extra bundles are removed, newest by mtime wins). The CSS side deletes first and asks questions never.

Related contract: pkgs/id/src/web/assets.rs is_hashed_filename (#6779) pins the emitted names (styles. + exactly 8 lowercase hex + .css); the deletion regex in the script ([a-f0-9]+, any length) is also broader than that contract.

Why it matters

A build step that destroys a built artifact on re-run, silently, turns a benign retry into a broken deployment: the server keeps serving pages whose stylesheet 404s. Nothing fails — not the script, not the server startup, not the manifest parse — so the breakage surfaces only as a visibly unstyled UI, far from the cause.

Acceptance criteria

  • Running build-manifest.ts twice in a row on the same dist/ leaves the stylesheet file in place and manifest.json still maps styles.css to it (idempotent re-run).
  • A re-run with no unhashed styles.css but an existing contract-valid styles.<8-hex>.css adopts that file into the manifest instead of deleting it (or fails loudly naming the missing input — silently dropping the entry is the one unacceptable outcome).
  • Stale-stylesheet cleanup still works: when build:css produces a new styles.css whose hash differs, the old hashed file is removed and the manifest points at the new one.
  • The deletion/adoption patterns match the id(web/assets): is_hashed_filename treats any 8+ lowercase dotted segment as a content hash — ordinary names (app.development.js, styles.darkmode.css) get a one-year immutable Cache-Control at a stable URL #6779 emitted-name contract in assets.rs (exactly 8 hex chars for styles), or the divergence is explicitly justified in a comment.
  • A regression test or fixture script exercises the double-run case (the probe above is a ready-made repro).

Activity

  1. added
    kind/bugSomething isn't working (prefixed form of the classic bug label)
    task/small-fixQueue packet kind: bounded fix with reproduction and targeted tests
    source/creatorFiled by the new-issue-creator job
    priority/normalOrdinary priority (the default)
    on Nov 7, 2026
  2. developing-today commented on Nov 7, 2026

    @developing-today
    Contributor
  3. added
    app/idPackage/app: id (pkgs/ or apps/ in this repo)
    on Nov 7, 2026
  4. dezren39 commented on Nov 7, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · state: filed

    • Agent: new-issue-creator job (lane A, new-issue-creator-code-a)
    • Session / ID: cron new-issue-creator-code-a, run 2026-11-07 16:35 CST
    • Found via: filed this run
    • Task: build-manifest.ts is not idempotent — a second run deletes the only hashed stylesheet and writes a manifest with no styles.css entry (server silently falls back to a nonexistent /assets/styles.css). Verified by laptop probe: fixture dist run twice, run 2 lost styles.74d94aed.css + the manifest entry, exit 0.
    • Expectation: effort s — make the CSS step adopt-or-fail-loudly on re-run instead of delete-first; regression coverage for the double-run case per the issue's acceptance criteria.
    • Links: probe ~/git/fleet/probe-build-manifest (laptop); body file creator-a-2026-11-07-1735/issue-body.md in the goal hidden_files
  5. added
    work/assignedQueue worker lifecycle state
    queue/claimedQueue worker lifecycle state
    and removed on Nov 8, 2026
  6. developing-today commented on Nov 8, 2026

    @developing-today
    Contributor

    🤖 Agent note · picked up

  7. 4 remaining items

  8. added
    queue/parkedQueue task is parked (waiting on CI, time, or an event)
    status/parkedDeliberately paused with a recorded resume condition
    queue/claimedQueue worker lifecycle state
    and removed
    status/parkedDeliberately paused with a recorded resume condition
    queue/parkedQueue task is parked (waiting on CI, time, or an event)
    on Nov 8, 2026
  9. dezren39 commented on Nov 8, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · picked up

  10. dezren39 commented on Nov 9, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    app/idPackage/app: id (pkgs/ or apps/ in this repo)kind/bugSomething isn't working (prefixed form of the classic bug label)priority/normalOrdinary priority (the default)source/creatorFiled by the new-issue-creator jobstatus:donetask/small-fixQueue packet kind: bounded fix with reproduction and targeted tests

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions