You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
TypeError: Cannot read private member #state when using paraglideMiddleware with TanStack Start 1.145+ #573
When using paraglideMiddleware with TanStack Start 1.145.x, the following error occurs:
TypeError: Cannot read private member #state from an object whose class did not declare it
at new Request (node:internal/deps/undici/undici:10426:27)
at paraglideMiddleware (/path/to/src/paraglide/server.js:108:13)
constnewRequest=runtime.strategy.includes("url")
? newRequest(runtime.deLocalizeUrl(request.url),request)
: // need to create a new request object because some metaframeworks (nextjs!) throw otherwise// https://github.com/opral/inlang-paraglide-js/issues/411newRequest(request);
TanStack Start 1.143+ refactored their middleware implementation (TanStack/router#5517) and now uses a custom Request object that is incompatible with Node's undici Request cloning via new Request(existingRequest).
When the url strategy is not used, the code tries to clone the request with new Request(request), which fails because undici's Request constructor cannot access the private #state field from TanStack's custom Request implementation.
Workaround
Modifying the generated server.js to skip cloning when url strategy is not used:
constnewRequest=runtime.strategy.includes("url")
? newRequest(runtime.deLocalizeUrl(request.url),request)
: request;// Don't clone, pass through directly
This works because when the URL strategy is not in use, there's no need to modify the request URL anyway.
Suggested Fix
Consider checking if cloning is actually necessary before attempting it. When the url strategy is not used, the original request can be passed through without modification.
Alternatively, a try-catch could be added to fall back to passing the original request if cloning fails.
The workaround would break nextjs as the comment specifies why a new request is created even if URL is not used. Thus, I am hesitant to merge your workaround
const newRequest = runtime.strategy.includes("url")
? new Request(runtime.deLocalizeUrl(request.url), request)
- : // need to create a new request object because some metaframeworks (nextjs!) throw otherwise- // https://github.com/opral/inlang-paraglide-js/issues/411
new Request(request);
@samuelstroschein These issues are related but distinct. Root cause is the same: Both stem from TanStack Start 1.143+ using custom Request wrappers (h3/srvx) with private fields (#state) that Node's undici Request constructor cannot access.
However, they manifest differently:
Where the fix should live: Technically, I believe this is a TanStack-side issue. Using new Request(existingRequest) is a standard Fetch API pattern for cloning requests, and custom Request implementations should be compatible with this usage.
However, for better user experience, it makes sense for paraglide-js to also handle this defensively with a try-catch fallback.
Of course, I respect your decision. As a TanStack Start user, I also add a comment in the TanStack Router repository if that would be more appropriate. (TanStack/router#6089 (comment))
I will test NextJS today if it still has the throwing behavior if the original request is passed through. If it doesn't, we could drop the clone approach.
Activity
fix: handle custom Request objects that cannot be cloned
samuelstroschein commentedon Jan 3, 2026
@iktakahiro Is this bug unrelated to the fixed bug TanStack/router#6089?
The workaround would break nextjs as the comment specifies why a new request is created even if URL is not used. Thus, I am hesitant to merge your workaround
const newRequest = runtime.strategy.includes("url") ? new Request(runtime.deLocalizeUrl(request.url), request) - : // need to create a new request object because some metaframeworks (nextjs!) throw otherwise - // https://github.com/opral/inlang-paraglide-js/issues/411 new Request(request);iktakahiro commentedon Jan 4, 2026
@samuelstroschein These issues are related but distinct. Root cause is the same: Both stem from TanStack Start 1.143+ using custom Request wrappers (h3/srvx) with private fields (#state) that Node's undici Request constructor cannot access.
However, they manifest differently:
Where the fix should live: Technically, I believe this is a TanStack-side issue. Using new Request(existingRequest) is a standard Fetch API pattern for cloning requests, and custom Request implementations should be compatible with this usage.
However, for better user experience, it makes sense for paraglide-js to also handle this defensively with a try-catch fallback.
Of course, I respect your decision. As a TanStack Start user, I also add a comment in the TanStack Router repository if that would be more appropriate. (TanStack/router#6089 (comment))
samuelstroschein commentedon Jan 5, 2026
@iktakahiro thanks for the detailed write up.
I will test NextJS today if it still has the throwing behavior if the original request is passed through. If it doesn't, we could drop the clone approach.
Alternatively, we can use request.clone() directly as it's also a standard web API https://developer.mozilla.org/en-US/docs/Web/API/Request/clone as per TanStack/router#6089 (comment) comment
samuelstroschein commentedon Jan 6, 2026
The PR fixes the issue. Will merge it.
Another issue opened up though: #576