cloudflare / cloudflare/vinext

nitro/bun preset: `_next/static` client manifests not emitted + `_next/static` misses return HTML 404 instead of plain-text

Open
#3,223 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
8.8k
Forks
406
Avg merge
2d 6h
Merged PRs (30d)
120

Description

_Found running the official Next.js e2e test suite against vinext (vinext 1.0.0-beta.8, `nitro({ preset: 'bun' })`, Next.js 16.2 corpus, ESM app). Two related `_next/static` gaps on the nitro-bun adapter path._

## Bug 1 — client runtime manifests are never emitted by the build

`emitNextClientRuntimeManifests` (`dist/build/next-client-runtime-manifests.js`) writes `_buildManifest.js` (`self.__BUILD_MANIFEST = …`) and `_ssgManifest.js`, but it is **exported and never invoked** anywhere in the build pipeline — `grep -rn "next-client-runtime-manifests\|emitNextClientRuntimeManifests\|__BUILD_MANIFEST" dist/` returns only the module's own definition (checked in beta.8 and beta.4). So `vite build` never writes `_next/static//_buildManifest.js` / `_ssgManifest.js`.

- **Repro:** build any app-router or pages-router app; `GET /_next/static//_buildManifest.js`.
- **Expected (Next.js):** `200`, body `self.__BUILD_MANIFEST = {…}`.
- **Actual (vinext):** `404`.

## Bug 2 — nitro/bun adapter doesn't short-circuit `_next/static` misses to a plain-text 404

vinext has the correct handler — `notFoundStaticAssetResponse()` (`dist/server/http-error-responses.js`, returns `text/plain` `"Not Found"`) — and wires it into `startProdServer` (`dist/server/prod-server.js`) and the Cloudflare worker entries (`app-router-entry.js`, `pages-router-entry.js` via `isNextStaticPath`). But the **nitro bun preset** request path is neither, so an unmatched `_next/static` path falls through to the app's rendered custom-not-found **HTML**.

- **Repro:** `GET /_next/static//.js` on a bun-preset build of an app with a custom `not-found`.
- **Expected (Next.js, and vinext's own standalone/worker paths):** `404`, `Content-Type: text/plain`, body `Not Found`.
- **Actual (vinext bun preset):** `404` with the app's custom-not-found HTML.

## Affected official e2e fixtures (8)

`invalid-static-asset-404-app` (+`-asset-prefix`, +`-base-path`), `invalid-static-asset-404-pages` (+`-asset-prefix`, +`-base-path`), `middleware-custom-matchers-i18n` (only failing case is the `_buildManifest.js` 200-check), `app-dir/asset-prefix-absolute`.

Contributor guide

Open the contributing guide

Research direction

Start by tracing emitNextClientRuntimeManifests in dist/build/next-client-runtime-manifests.js through the build pipeline, then compare the _next/static handling in dist/server/prod-server.js and the app-router-entry.js and pages-router-entry.js worker entries. Run the affected official e2e fixtures, including the invalid-static-asset-404 and middleware-custom-matchers-i18n cases. Done means manifests return 200 and missing _next/static paths return a plain-text Not Found 404 under the nitro/bun preset.

Written by the indexing model from the issue text.

Assessment

Tech stack
bun, nextjs, typescript, vite
Domain
backend, build-system, testing
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.