Skip to content

fix(routing): keep npm API routes portable on Node - #3970

Merged
kojiwakayama merged 1 commit into
mainfrom
fix/issue-3968-node-api-route-hash
Aug 22, 2026
Merged

kojiwakayama merged 1 commit into
mainfrom
fix/issue-3968-node-api-route-hash

Conversation

@kojiwakayama

Copy link
Copy Markdown
Contributor

Outcome

Restores every API route in the published npm package on stock supported Node releases and prepares 0.1.1250-rc for immediate validation.

Closes #3968.

Root cause

The API module loader converted SHA-256 digests with Uint8Array.prototype.toHex(). Deno exposes that method, but stock Node 22 and Node 24 do not. The shipped dnt artifact therefore started normally and failed only when an API route loaded.

The user-wide regression entered in #3912 on 2026-08-21 when content hashes became the cache key for both direct and bundled routes. A narrower instance had already entered the isolated route-preparation path in #3285 on 2026-08-02.

CI stayed green because:

  • the Node runner excludes an entire test file when its source contains Deno., and the loader suite includes Deno-specific filesystem cases;
  • the clean-room npm smoke started the packed dev server and requested /, but never requested an API route.

Fix

  • Route all three loader SHA-256 operations through the existing cross-runtime computeHash utility.
  • Delete the duplicate loader-local hash encoder.
  • Extend the clean-room packed npm smoke with a real app/api/npm-smoke/route.ts and require exact 200 {"ok":true} behavior.
  • Advance synchronized release metadata to 0.1.1250-rc.

Verification

  • Before the fix, the new Node 24 smoke failed with the reported toHex is not a function and HTTP 500.
  • After the fix, the full packed npm page + API-route smoke passes on Node 22.23.2 and Node 24.19.0.
  • Module loader: 63 steps passed.
  • Shared hash utility: 24 steps passed.
  • Full pre-push gate passed: format, lint, typecheck, and unit tests.

Release plan

Publish and probe the unique 0.1.1250-rc artifact first, then promote the same commit without code divergence to stable 0.1.1250.

API-route module hashing used Uint8Array.prototype.toHex(), which is unavailable in supported stock Node 22 and Node 24. Route all loader hashes through the existing hardened cross-runtime SHA-256 utility and extend the packed npm smoke to request a real API route.

Constraint: The npm package supports stock Node 22+ without runtime flags.

Rejected: Add a toHex shim or runtime flag | both hide a Deno-specific dependency instead of removing it.

Confidence: high

Scope-risk: narrow

Directive: Keep published-runtime hashing on the shared computeHash boundary and retain the packed API-route smoke.

Tested: Loader 63 steps; hash utility 24 steps; packed npm page and API route on Node 22.23.2 and 24.19.0.

Not-tested: Registry-published RC artifact; CI performs that release-stage validation.

Related: #3968
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@coderabbitai

coderabbitai Bot commented Aug 22, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@kojiwakayama, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 7 minutes

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

Wait for the limit to reset, then comment @coderabbitai review or push new commits to the PR.

An organization admin can change what happens after included review limits in Billing.

How do review limits work?

CodeRabbit enforces per-developer PR review limits within each organization.

For paid Pro and Pro+ reviews, CodeRabbit uses a developer's included PR review attempts over the past 7 days to set the current hourly allowance. At typical activity levels, the full plan allowance applies. Higher sustained activity can lower the allowance until earlier attempts leave the 7-day window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 1284a461-17ee-471d-a86a-1a2a9cdc450a

📥 Commits

Reviewing files that changed from the base of the PR and between 8b02b7f and d358e64.

⛔ Files ignored due to path filters (1)
  • src/html/hydration-script-builder/hydration-runtime.generated.ts is excluded by !**/*.generated.*
📒 Files selected for processing (4)
  • deno.json
  • scripts/test/npm-install-smoke.sh
  • src/routing/api/module-loader/loader.ts
  • src/utils/version-constant.ts

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.

@github-actions

Copy link
Copy Markdown

📦 Client bundle boundary

Entrypoint Modules Source size Server leaks
src/index.client.ts 327 1960 KiB ✅ 0

A server module in a client graph aborts hydration in the browser. New leaks fail CI; known leaks are tracked in scripts/lint/client-bundle-baseline.json to burn down.

@kojiwakayama
kojiwakayama enabled auto-merge August 22, 2026 11:03
@kojiwakayama
kojiwakayama added this pull request to the merge queue Aug 22, 2026
Merged via the queue into main with commit ce033bf Aug 22, 2026
36 checks passed
@kojiwakayama
kojiwakayama deleted the fix/issue-3968-node-api-route-hash branch August 22, 2026 11:21
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.

[BUG] Every API route fails to load on stock Node — module loader calls Deno-native Uint8Array.prototype.toHex()

1 participant