Skip to content

ignore - #5681

Closed
KATT wants to merge 56 commits into
issues/5659-multi-body-readfrom
04-26-resolveResponse+multi
Closed

ignore#5681
KATT wants to merge 56 commits into
issues/5659-multi-body-readfrom
04-26-resolveResponse+multi

Conversation

@KATT

@KATT KATT commented Apr 27, 2024 •

Copy link
Copy Markdown
Member

No description provided.

Comment on lines +12 to +43
let size = 0;
const maxBodySize = opts.maxBodySize;

let controller: ReadableStreamDefaultController<Value> =
null as unknown as ReadableStreamDefaultController<Value>;
const stream = new ReadableStream<Value>({
start(c) {
controller = c;
},
async pull(c) {
const chunk: Value = req.read();

if (chunk) {
size += chunk.length;
}
if (maxBodySize !== null && size > maxBodySize) {
controller.error(
new TRPCError({
code: 'PAYLOAD_TOO_LARGE',
}),
);
return;
}
if (chunk === null) {
c.close();
return;
}
controller.enqueue(chunk);
},
cancel() {
req.destroy();
},

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Considering dropping maxBodySize in order to simplify this, it can be replaced by just using the IncomingMessage as the body (as it is a stream)

@github-actions

Copy link
Copy Markdown
Contributor

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.

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Apr 29, 2024

This branch was successfully deployed

5 active deployments
Preview – www β€” 496fc8f8 Deployed Apr 28, 2024 by vercel[bot]
Preview – next-prisma-starter β€” 496fc8f8 Deployed Apr 28, 2024 by vercel[bot]
Preview – trpc-next-app-dir β€” 496fc8f8 Deployed Apr 28, 2024 by vercel[bot]
Preview – todomvc β€” 496fc8f8 Deployed Apr 28, 2024 by vercel[bot]
Preview – og-image β€” 496fc8f8 Deployed Apr 28, 2024 by vercel[bot]
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants