-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
fix(server): transformer at top level for httpBatchStreamLink
#6457
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
Conversation
WalkthroughThe changes introduce a regression test that validates the encoding and decoding of Date objects using SuperJSON at the top level. The new test constructs a data structure with a Promise resolving to a Date, splits the resulting stream using tee, and verifies the deserialized output against an inline snapshot. In addition, the encoding logic within the createBatchStreamProducer function (in jsonl.ts) is enhanced with conditional handling for asynchronous and non-object values. Changes
Sequence Diagram(s)sequenceDiagram
participant T as Test Runner
participant P as jsonlStreamProducer
participant TE as Tee Method
participant C as jsonlStreamConsumer
T ->> P: Send data structure with Promise(Date)
P ->> P: Process encoding (async call & type-check)
P ->> TE: Split stream using tee()
TE ->> T: Return aggregated output from second stream
T ->> C: Pass first stream data for deserialization
C ->> T: Return decoded data (verified as Date instance)
Assessment against linked issues
Poem
β¨ Finishing Touches
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? πͺ§ TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
|
π Previously deployed to Railway in the trpc-sse-and-websockets project. Environment has been deleted. |
commit: |
|
The latest updates on your projects. Learn more about Vercel for Git βοΈ
|
unstable_httpBatchStreamLinkhttpBatchStreamLink
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/server/src/unstable-core-do-not-import/stream/jsonl.ts (1)
236-244: Good enhancement to handle special objects!The changes improve the handling of non-plain objects (like Date) and async values. The implementation correctly uses
Object.prototype.toString.call()to distinguish between plain objects and special objects.Consider extracting the object type check into a named function for better readability:
+function isPlainObject(value: unknown): boolean { + return Object.prototype.toString.call(value) === '[object Object]'; +} + function encode(value: unknown, path: (string | number)[]): EncodedValue { if (value === undefined) { return [[]]; } if (!isObject(value)) { return [[value]]; } const reg = encodeAsync(value, path); if (reg) { return [[placeholder], [null, ...reg]]; } - if (Object.prototype.toString.call(value) !== '[object Object]') { + if (!isPlainObject(value)) { return [[value]]; }
π Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
π Files selected for processing (2)
packages/server/src/unstable-core-do-not-import/stream/jsonl.test.ts(1 hunks)packages/server/src/unstable-core-do-not-import/stream/jsonl.ts(1 hunks)
β° Context from checks skipped due to timeout of 90000ms (18)
- GitHub Check: E2E-tests (vercel-edge-runtime)
- GitHub Check: E2E-tests (tanstack-start)
- GitHub Check: E2E-tests (standalone-server)
- GitHub Check: E2E-tests (soa)
- GitHub Check: E2E-tests (next-prisma-websockets-starter)
- GitHub Check: E2E-tests (next-prisma-todomvc)
- GitHub Check: E2E-tests (next-prisma-starter)
- GitHub Check: E2E-tests (next-minimal-starter)
- GitHub Check: E2E-tests (next-formdata)
- GitHub Check: E2E-tests (minimal-react)
- GitHub Check: e2e-legacy-node (next-prisma-todomvc, 20.x)
- GitHub Check: e2e-legacy-node (next-prisma-todomvc, 18.x)
- GitHub Check: e2e-legacy-node (next-prisma-websockets-starter, 20.x)
- GitHub Check: e2e-legacy-node (next-prisma-websockets-starter, 18.x)
- GitHub Check: e2e-legacy-node (next-prisma-starter, 20.x)
- GitHub Check: E2E-tests (.experimental/next-app-dir)
- GitHub Check: e2e-legacy-node (next-prisma-starter, 18.x)
- GitHub Check: Lint and auto-fix
π Additional comments (1)
packages/server/src/unstable-core-do-not-import/stream/jsonl.test.ts (1)
630-684: Well-structured regression test!The test thoroughly validates the encoding and decoding of Date objects using SuperJSON at the top level. It covers:
- Proper serialization of Promise
- Stream handling with tee
- Correct deserialization back to Date object
- Timestamp verification
|
This pull request has been locked because we are very unlikely to see comments on closed issues. If you think, this PR is still necessary, create a new one with the same branch. Thank you. |
Closes #6464
π― Changes
Fix for
unstable_httpBatchStreamLink& transformers at top levelβ Checklist
Summary by CodeRabbit
These internal improvements aim to boost the overall reliability of our data streaming mechanism while preserving the correct handling of date information.