Skip to content

fix(server): serve the static build output in the production server - #47

Merged
ecv merged 1 commit into
mainfrom
polylane/autofix/0ai4phm0azs1
Nov 9, 2026
Merged

ecv merged 1 commit into
mainfrom
polylane/autofix/0ai4phm0azs1

Conversation

@polylane

@polylane polylane Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

The production server this project ships could not start. The site builds as a static bundle, but the server expected a server-rendered build and stopped on its first import, so nothing was served on port 4321 for anyone running the documented production path. After this change the server serves the built site and returns the project's own 404 page for unknown paths.

flowchart TD
  A["astro.config.mjs: output static, no adapter"] --> B["astro build writes dist/index.html and dist/404.html"]
  B --> C["no dist/server/entry.mjs, no dist/client"]
  C --> D["server.mjs import on line 2 throws"]
  D --> E["container exits, nothing listens on 4321"]
  F["fix: server serves dist and the prerendered 404 page"] --> G["server listens on 4321 and serves the site"]
  H["Pages workflow uploads dist"] --> I["www.cloudvalid.com serves fine, unchanged"]
Loading

Fix walkthrough

Watch the fix walkthrough

Watch the fix explained (1:17). Recorded for commit 68febe43bab60a476402fe79bb3aa4517125404b.

Detection evidence

Affected: int_17ad4b457001o98datdn4tkm

Why this fix

The declared production entrypoint imported a bundle the static Astro build never emits, and I reproduced the crash locally. Testing the alternative fix showed that restoring the node adapter moves prerendered pages under a subdirectory and drops index.html from the artifact root, which would break the GitHub Pages deploy that serves the live site. The remaining failure is that bun run build itself still breaks on an unrelated dependency-resolution defect, tracked separately.

Out of scope
  • Removing the unused @astrojs/node dependency: bun remove also downgraded an unrelated transitive package in bun.lock, so I left that for a separate dependency change.
  • The js-yaml build failure that blocks bun run build and docker build: a separate dependency-resolution defect, tracked separately.

Production impact: Server serves the same built files it always intended to

The cloudvalid.com repository has no deploy edges in the infrastructure graph: no workflow builds its Docker image, and production is GitHub Pages. The changed file is not read by that Pages build. I verified the change locally against a built static site: /, /docs, and assets return 200 and an unknown path returns the prerendered 404 page.

Observability

  • server.mjs startup banner prints which subsystems are enabled.
  • With NODE_ENV unset it logs one line per request ([timestamp] METHOD url); in production that log is suppressed by design.

Polylane assessed this pull request at 8e0db96.

Causal chain
  • Signal (log template): error: Cannot find module './dist/server/entry.mjs' from '.../server.mjs'
  • Surfacing site: datum-cloud/cloudvalid.com at datum-cloud/cloudvalid.com:server.mjs#module-load
  • Mechanism: astro.config.mjs sets output 'static' with no adapter, so astro build writes pages at the dist root and emits neither dist/server/entry.mjs nor dist/client; server.mjs imports ./dist/server/entry.mjs at line 2 and reads dist/client at line 13, so the process throws before listening.
  • Producer: cloudvalid.com build and server configuration, at datum-cloud/cloudvalid.com:astro.config.mjs + server.mjs
  • Trigger: Commit b712e91 removed the node adapter from astro.config.mjs while server.mjs kept expecting the SSR output layout.
  • What happens to the failed unit today: server.mjs serves health probes and static files and previously delegated unmatched routes to the Astro handler from dist/server/entry.mjs.
  • Blast radius: 0 other resource(s), 0 other tenant(s); data at risk: none named
  • Producer evidence:
    • server.mjs line 2 imports ./dist/server/entry.mjs and line 13 sets CLIENT_DIR to dist/client; astro.config.mjs sets output 'static' with only the starlight integration and no adapter.
    • Local build with Astro 7.1.6: dist contains index.html, 404.html, docs/index.html, _astro/, pagefind/ and no server/ or client/ directories.
    • Local run: bun run ./server.mjs exits 1 with Cannot find module './dist/server/entry.mjs'.
    • git 2af087d (initial commit) carried adapter: node({mode:'middleware'}); b712e91 removed the adapter without touching server.mjs, Dockerfile, docker-compose.yml, or the start script.

View autofix


Generated by Polylane. You can ask follow-ups by mentioning @polylane in a comment.

@polylane polylane Bot added the polylane label Oct 27, 2026
@polylane
polylane Bot requested review from AriaEdo and scotwells October 27, 2026 00:59
scotwells
scotwells previously approved these changes Oct 28, 2026
@ecv ecv closed this Nov 3, 2026
@ecv ecv reopened this Nov 3, 2026
@ecv
ecv force-pushed the polylane/autofix/0ai4phm0azs1 branch from 8e0db96 to 68febe4 Compare November 9, 2026 13:14
@ecv
ecv requested a review from scotwells November 9, 2026 13:14
Co-authored-by: polylane[bot] <277585245+polylane[bot]@users.noreply.github.com>
@ecv
ecv force-pushed the polylane/autofix/0ai4phm0azs1 branch from 68febe4 to 8df450e Compare November 9, 2026 13:26
@ecv
ecv requested a review from scotwells November 9, 2026 13:26
@ecv
ecv merged commit 27bcec0 into main Nov 9, 2026
3 checks passed
@ecv
ecv deleted the polylane/autofix/0ai4phm0azs1 branch November 9, 2026 13:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants