refactor(tanstack-start): reuse TanStack request context - #2191
Open
bgub wants to merge 1 commit into
Open
Conversation
Contributor
size-limit report 📦
|
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.
TL;DR
Reuse TanStack Start's existing request context instead of maintaining a second
AsyncLocalStorage-backed condition store. Server translation helpers now resolve and memoize conditions directly from TanStack's currentRequest, sogtMiddlewareis optional.Code Changes
AsyncLocalConditionStoreand its singleton plumbing.getRequest()and memoize them per request.parseLocale()to a deprecated alias forgetLocale().gtMiddlewareas a compatibility/eager-warming hook.Notes / Flags
gtMiddlewareregistrations continue to work./servercompatibility entry grows from 1.66 kB to 2.47 kB because it now includes direct request resolution.Greptile Summary
Summary
This change replaces the TanStack Start adapter’s async-local request state with conditions resolved from TanStack’s active request, memoized per request, and shared across package instances. It also makes
gtMiddlewarean optional compatibility hook and uses the shared React browser condition store during client initialization.Focused execution disproved the relevant failure hypotheses: runtime helpers resolved the active request without middleware, separate requests retained separate locale and enablement values while repeated reads reused the same conditions, and a path locale did not override the cookie locale when locale routing was disabled. The related request-condition and runtime tests passed, and the package typecheck completed successfully.
No defects were found.
Confidence Score: 5/5
The changed TanStack Start request-condition behavior is safe to merge based on the exercised request-resolution, isolation, memoization, and locale-routing paths.
Focused executable coverage exercised the key behavior introduced by this change, while the adjacent changed-module tests and package typecheck also completed successfully. No independently actionable defects remain.
Files Needing Attention: No files need follow-up attention. The exercised implementation paths were packages/tanstack-start/src/functions/requestConditions.ts and packages/tanstack-start/src/functions/runtime.ts.
What T-Rex did
Reviews (1): Last reviewed commit: "refactor(tanstack-start): reuse TanStack..." | Re-trigger Greptile