Skip to content

fix(build): write public assets in a stable order - #4975

Merged
pi0 merged 1 commit into
nitrojs:mainfrom
onmax:fix/public-assets-manifest-order
Nov 1, 2026
Merged

pi0 merged 1 commit into
nitrojs:mainfrom
onmax:fix/public-assets-manifest-order

Conversation

@onmax

@onmax onmax commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Linked issue

closes #4972

Type of change

  • Bug fix

Description

Public asset metadata is inserted into the manifest as concurrent file reads finish, so the generated server output can change between identical builds.

Sort the completed manifest by asset path before serializing it, using a locale-independent comparator. Add a regression test that checks the emitted key order.

This addresses manifest ordering only. Copied asset mtimes still vary between builds, and paths that decode to the same key can still overwrite each other according to read completion order. Those need separate fixes.

Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly. No public API changes.

The public asset manifest listed files in the order their reads finished, so two builds of the same app gave different server chunks. Sort the entries by path.
@onmax
onmax requested a review from pi0 as a code owner October 30, 2026 16:18
@vercel

vercel Bot commented Oct 30, 2026

Copy link
Copy Markdown

@onmax is attempting to deploy a commit to the Nitro Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 76a7d70b-09f2-4173-bacc-485f0e26683b
Commits

Reviewing files that changed from the base of the PR and between f794c37 and bb07c73.

Files selected for processing: 2
  • src/build/virtual/public-assets.ts
  • test/unit/public-assets.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

Walkthrough

The production public-assets manifest now sorts entries by asset ID before serialization. A unit test creates 40 public files and checks that generated manifest keys follow filename order.

Changes: Public asset manifest ordering

Layer / File(s) Summary
Sort manifest entries and verify key order
src/build/virtual/public-assets.ts, test/unit/public-assets.test.ts
The generated manifest sorts asset entries by ID before serialization. The test checks key order for 40 generated public files and removes its temporary directory after each test.

Priority: Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Possibly related issues

  • Issue 4972 reports nondeterministic build output caused by public files being added in read-completion order. This change sorts manifest entries, but does not address copied-file modification times.
Merge Risk: Minimal · up to bb07c

No actionable merge-blocking risk is identified in this focused ordering change. Merge after normal checks; broader reported test failures remain unattributed.

Pre-merge checks: Passed 5
Check name Status Explanation
Title check Passed The title "fix(build): write public assets in a stable order" follows the Conventional Commits format with a type (fix), a scope (build), and a colon-separated description. It matches the main change:…
Docstring Coverage Passed No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description check Passed The description clearly explains the manifest-ordering fix, the locale-independent sorting, and the regression test. It directly matches the changeset.
Full details: Title check

Explanation

The title "fix(build): write public assets in a stable order" follows the Conventional Commits format with a type (fix), a scope (build), and a colon-separated description. It matches the main change: the public-assets manifest is now sorted by asset path before serialization, so the output is stable across builds.

Full details: Docstring Coverage

Explanation

No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 0 functions across 2 files.

Finishing Touches: 💡 1
🛠️ Fix failing CI checks: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@pkg-pr-new

pkg-pr-new Bot commented Oct 30, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/nitro@4975

commit: bb07c73

@pi0
pi0 merged commit cbf0add into nitrojs:main Nov 1, 2026
15 of 16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Two builds of the same app give different server output

2 participants