mirror of
https://github.com/cloudflare/vinext.git
synced 2026-05-09 08:25:34 +02:00
[PR #1070] [MERGED] refactor(app-browser-entry): dedupe encoded JSON header parsing #1066
Labels
No labels
enhancement
enhancement
good first issue
help wanted
nextjs-tracking
nextjs-tracking
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/vinext#1066
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/cloudflare/vinext/pull/1070
Author: @james-elicx
Created: 5/5/2026
Status: ✅ Merged
Merged: 5/5/2026
Merged by: @james-elicx
Base:
main← Head:refactor/dedupe-encoded-json-header📝 Commits (1)
7e0b27crefactor(app-browser-entry): dedupe encoded JSON header parsing📊 Changes
1 file changed (+27 additions, -18 deletions)
View changed files
📝
packages/vinext/src/server/app-browser-entry.ts(+27 -18)📄 Description
Summary
try { JSON.parse(decodeURIComponent(headerValue)) } catch { ... }pattern used to hydrate params from theX-Vinext-Paramsheader into a single local helper,parseEncodedJsonHeader<T>(value: string | null): T | null.packages/vinext/src/server/app-browser-entry.ts(the initial RSC hydration path and the in-flight navigation path) now share the helper.Follow-up to #1049.
Files changed
packages/vinext/src/server/app-browser-entry.ts— adds the helper at the top of the file and updates the two call sites.Notes on behavior preservation
The two original blocks had a subtle difference:
applyClientParams(params)inside the sametry, so the catch silently swallowed any error fromapplyClientParamsas well.The helper itself only handles parsing. To preserve the original error-swallowing semantics at the first call site,
applyClientParamsis wrapped in a small dedicatedtry/catchthere. The helper does not log or surface errors — silent by design, matching the pre-existing behavior.A quick
grep -rn "JSON.parse(decodeURIComponent" packages/vinext/src/confirmed the pattern only appears in this file, so a module-private helper (rather than a shared utility) is sufficient.Test plan
pnpm vp test run tests/app-router.test.ts— 308 tests passpnpm fmt --writeon the touched file🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.