-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
fix(start-server-core): deserialize tss context when using formdata #5935
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(start-server-core): deserialize tss context when using formdata #5935
Conversation
WalkthroughReplaces ad-hoc JSON parsing of a serialized middleware context with seroval plugin-based deserialization in the server handler, and adds a new FormData-driven test route + UI and an e2e test that verifies client middleware context propagation when sending FormData. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant Browser
participant ClientMiddleware
participant Fetch(FormData)
participant ServerHandler
participant Seroval
participant ServerMiddleware
participant ServerFunction
Browser->>ClientMiddleware: run client middleware -> sendContext(testString)
ClientMiddleware->>Fetch(FormData): create FormData + attach serializedContext
Fetch(FormData)->>ServerHandler: POST with FormData + serializedContext
ServerHandler->>Seroval: fromJSON(serializedContext, plugins)
Seroval-->>ServerHandler: deserializedContext
ServerHandler->>ServerMiddleware: invoke with merged context
ServerMiddleware->>ServerFunction: call function (context available)
ServerFunction-->>Browser: JSON response (includes context/testString)
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (3)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
packages/start-server-core/src/server-functions-handler.ts (1)
95-95: Consider logging deserialization errors for debugging.The empty catch block silently swallows errors during context deserialization. While this provides fail-safe behavior (falling back to the original context), adding a debug log would aid troubleshooting.
Apply this diff to add error logging:
- } catch {} + } catch (error) { + console.debug('Failed to deserialize FormData context:', error) + }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
packages/start-server-core/src/server-functions-handler.ts(1 hunks)
🔇 Additional comments (1)
packages/start-server-core/src/server-functions-handler.ts (1)
91-93: LGTM! Proper deserialization with seroval plugins.The use of
fromJSONwith seroval plugins correctly deserializes the context, enabling support for complex types (Dates, Maps, Sets, etc.) thatJSON.parsealone cannot handle. This brings the FormData context deserialization in line with theparsePayloadfunction used elsewhere in the code.
|
thanks! we should also add a testcase to the e2e server functions test |
Added a test similar to my reproducer and ran it. Seems to work along with the other tests. |
|
View your CI Pipeline Execution ↗ for commit 72c6461
☁️ Nx Cloud last updated this comment at |
|
Anything else I need to add? |
Fixes #5913 where the client
TSS_CONTEXTis not deserialized when using formdataSummary by CodeRabbit
New Features
Refactor
Tests
✏️ Tip: You can customize this high-level summary in your review settings.