[PR #976] [MERGED] fix: forward invalid dynamic usage errors on client-side navigations in dev #998

Closed
opened 2026-05-06 13:11:28 +02:00 by BreizhHardware · 0 comments

📋 Pull Request Information

Original PR: https://github.com/cloudflare/vinext/pull/976
Author: @Divkix
Created: 4/30/2026
Status: Merged
Merged: 4/30/2026
Merged by: @james-elicx

Base: mainHead: fix/958-dynamic-usage-errors-client-nav


📝 Commits (2)

  • bb31e5a fix: forward invalid dynamic usage errors on client-side navigations in dev (#958)
  • 3b33d37 refactor: extract _recordInvalidDynamicUsageError helper in server.ts

📊 Changes

7 files changed (+223 additions, -12 deletions)

View changed files

📝 packages/vinext/src/entries/app-rsc-entry.ts (+2 -1)
📝 packages/vinext/src/server/app-page-render.ts (+82 -1)
📝 packages/vinext/src/shims/headers.ts (+41 -2)
📝 packages/vinext/src/shims/server.ts (+22 -2)
📝 packages/vinext/src/shims/unified-request-context.ts (+1 -0)
📝 tests/__snapshots__/entry-templates.test.ts.snap (+12 -6)
📝 tests/shims.test.ts (+63 -0)

📄 Description

Fixes #958

Summary

  • Records errors from throwIfInsideCacheScope() on the per-request context so they survive user-code try/catch and can surface on client-side navigations
  • In dev mode, wraps the RSC response body to check for recorded errors after stream consumption and logs them to console.error
  • Adds consumeInvalidDynamicUsageError() to next/headers for consuming the recorded error
  • Updates _throwIfInsideCacheScope in server.ts (used by after()) with the same recording behavior

Ported from Next.js: vercel/next.js@f5e54c0 (#93184)

Test plan

  • Added 3 unit tests to tests/shims.test.ts:
    • Error recording survives user try/catch
    • consumeInvalidDynamicUsageError returns null when no error recorded
    • consumeInvalidDynamicUsageError works outside unified request scope
  • All existing tests pass (shims, app-router, entry-templates, features, unified-request-context, app-page-render)

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/cloudflare/vinext/pull/976 **Author:** [@Divkix](https://github.com/Divkix) **Created:** 4/30/2026 **Status:** ✅ Merged **Merged:** 4/30/2026 **Merged by:** [@james-elicx](https://github.com/james-elicx) **Base:** `main` ← **Head:** `fix/958-dynamic-usage-errors-client-nav` --- ### 📝 Commits (2) - [`bb31e5a`](https://github.com/cloudflare/vinext/commit/bb31e5a77b2bcae0c03e64838c51ad64c627f9a4) fix: forward invalid dynamic usage errors on client-side navigations in dev (#958) - [`3b33d37`](https://github.com/cloudflare/vinext/commit/3b33d374e2d90d586ebc643a6a9bcf8517074ddc) refactor: extract _recordInvalidDynamicUsageError helper in server.ts ### 📊 Changes **7 files changed** (+223 additions, -12 deletions) <details> <summary>View changed files</summary> 📝 `packages/vinext/src/entries/app-rsc-entry.ts` (+2 -1) 📝 `packages/vinext/src/server/app-page-render.ts` (+82 -1) 📝 `packages/vinext/src/shims/headers.ts` (+41 -2) 📝 `packages/vinext/src/shims/server.ts` (+22 -2) 📝 `packages/vinext/src/shims/unified-request-context.ts` (+1 -0) 📝 `tests/__snapshots__/entry-templates.test.ts.snap` (+12 -6) 📝 `tests/shims.test.ts` (+63 -0) </details> ### 📄 Description Fixes #958 ## Summary - Records errors from `throwIfInsideCacheScope()` on the per-request context so they survive user-code `try`/`catch` and can surface on client-side navigations - In dev mode, wraps the RSC response body to check for recorded errors after stream consumption and logs them to `console.error` - Adds `consumeInvalidDynamicUsageError()` to `next/headers` for consuming the recorded error - Updates `_throwIfInsideCacheScope` in `server.ts` (used by `after()`) with the same recording behavior Ported from Next.js: vercel/next.js@f5e54c0 (#93184) ## Test plan - Added 3 unit tests to `tests/shims.test.ts`: - Error recording survives user try/catch - `consumeInvalidDynamicUsageError` returns null when no error recorded - `consumeInvalidDynamicUsageError` works outside unified request scope - All existing tests pass (shims, app-router, entry-templates, features, unified-request-context, app-page-render) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
BreizhHardware 2026-05-06 13:11:28 +02:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/vinext#998
No description provided.