Repository navigation
fix: handle custom Request objects that cannot be cloned - #574
Merged
samuelstroschein merged 3 commits intoJan 7, 2026
Merged
samuelstroschein merged 3 commits into
samuelstroschein merged 3 commits into
Conversation
Some frameworks like TanStack Start 1.143+ use custom Request implementations with private fields (e.g., #state) that cannot be cloned using `new Request(request)`. This causes a runtime error: "Cannot read private member #state from an object whose class did not declare it" When URL strategy is not used, the middleware now tries to clone the request but falls back to using the original request if cloning fails. This maintains backwards compatibility with frameworks like NextJS that require a new Request object while also supporting frameworks with custom Request implementations. Fixes generaltranslation#573 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
Contributor
|
@iktakahiro i'll merge this tomorrow. I am boarding a plane right now (and learned before that's it's a bad idea to merge a patch right before being offline for 18 hours) |
Contributor
Author
|
@samuelstroschein Have a safe flight! |
Contributor
|
@iktakahiro Thanks for the PR. Released as 2.7.2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
paraglideMiddlewarewith TanStack Start 1.143+Problem
TanStack Start 1.143+ uses a custom
Requestimplementation with private fields (#state). When paraglide-js tries to clone the request usingnew Request(request), Node's undiciRequestconstructor cannot access these private fields, causing the error:Solution
Instead of unconditionally cloning the request when URL strategy is not used, we now:
new Request(request)This approach:
Test plan
Fixes #573
Note
Adds defensive request cloning in
paraglideMiddlewareto support runtimes with customRequestwrappers.url, attemptnew Request(request)and fall back to the originalrequeston error;urlstrategy de-localization remains unchangedRequest(TanStack Start scenario)examples/tanstack-start/project.inlang/cacheWritten by Cursor Bugbot for commit b31a63e. This will update automatically on new commits. Configure here.