-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
ignore #5681
ignore #5681
Conversation
β¦26-resolveResponse
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(); | ||
}, |
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.
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)
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. |
No description provided.