Skip to content

fix(orama-db): make orama-db.json identical between builds - #1190

Open
dbisina wants to merge 1 commit into
nodejs:mainfrom
dbisina:fix/orama-db-deterministic-output
Open

dbisina wants to merge 1 commit into
nodejs:mainfrom
dbisina:fix/orama-db-deterministic-output

Conversation

@dbisina

@dbisina dbisina commented Oct 26, 2026

Copy link
Copy Markdown

Fixes #1184.

orama-db.json changed on every build for two reasons: documents were inserted without an id, so Orama made up a time-based one that is saved in the index, and the saved index follows insertion order, which depends on the order the generator's input arrives in.

This follows the approach in the issue, in packages/react/src/orama-db/generate.mjs only:

  • each document gets id: href;
  • the flattened documents are sorted by href with < / > (no locale), after the existing flatMap, so buildHierarchicalTitle still sees each module's headings in document order.

Added packages/react/src/orama-db/__tests__/generate.test.mjs: two runs give identical output, module input order doesn't matter, hierarchical titles are kept, and the saved index still loads and can be searched. The two determinism tests fail without the change. Also added a patch changeset for @doc-kit/generator-react.

Checks: oxlint and oxfmt --check pass on the changed files. node --run test reports 13 failures on both main and this branch (same count; I'm on Windows with Node 25, installed with the engine check relaxed), and 4 more passing tests with this change. I haven't built the full Node.js docs, so I haven't checked for duplicate hrefs in the real input; per the issue, Orama would throw DOCUMENT_ALREADY_EXISTS if there were any.

Documents were inserted without an id, so Orama generated a time-based one
that is saved in the index, and the saved index followed the generator's
input order, which can change between builds.

Use each document's href as its id and sort the documents by href (without
a locale) before inserting them. Add generator tests.
@dbisina
dbisina requested a review from a team as a code owner October 26, 2026 19:34
@vercel

vercel Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
api-docs-tooling Ready Ready Preview Oct 26, 2026 7:35pm UTC

Request Review

@ovflowd ovflowd left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your first contribution!

@codecov

codecov Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.68421% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 93.58%. Comparing base (ec7751f) to head (97c3afc).

Files with missing lines Patch % Lines
packages/react/src/orama-db/generate.mjs 90.90% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1190      +/-   ##
==========================================
+ Coverage   93.44%   93.58%   +0.13%     
==========================================
  Files         278      279       +1     
  Lines       27820    27895      +75     
  Branches     2790     2802      +12     
==========================================
+ Hits        25997    26106     +109     
+ Misses       1801     1767      -34     
  Partials       22       22              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions

Copy link
Copy Markdown
Contributor

api-links Generator

Performance estimate (single CI run)

  • Generation time: 34.6% faster (1.07 s → 700.00 ms)
  • Peak memory: 5.2% higher (289.13 MB → 304.30 MB)

json Generator

Performance estimate (single CI run)

  • Generation time: 42.9% slower (7.46 s → 10.66 s)
  • Peak memory: 2.6% lower (1.18 GB → 1.15 GB)

legacy-html Generator

Performance estimate (single CI run)

  • Generation time: 60.9% slower (10.58 s → 17.02 s)
  • Peak memory: 0.8% lower (1.79 GB → 1.77 GB)

legacy-json Generator

Performance estimate (single CI run)

  • Generation time: 16.3% faster (9.04 s → 7.57 s)
  • Peak memory: 3.5% higher (1.15 GB → 1.19 GB)

llms-txt Generator

Performance estimate (single CI run)

  • Generation time: 21.7% faster (8.10 s → 6.34 s)
  • Peak memory: 5.4% higher (1.19 GB → 1.25 GB)

orama-db Generator

Output size: 1 file changed · net +438.21 KB

File size details
File Main PR Change
orama-db.json 29.24 MB 29.66 MB +438.21 KB (+1.5%)

Performance estimate (single CI run)

  • Generation time: 2.9% slower (7.35 s → 7.56 s)
  • Peak memory: 2.6% lower (1.28 GB → 1.24 GB)

web Generator

Performance estimate (single CI run)

  • Generation time: 31.1% faster (22.42 s → 15.44 s)
  • Peak memory: 7.3% higher (1.90 GB → 2.04 GB)

This branch was successfully deployed

1 active deployment
Preview – api-docs-tooling — 97c3afcb Deployed Oct 26, 2026 by vercel[bot]
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.

orama-db: orama-db.json changes on every build

4 participants