Replies: 1 comment
-
|
Hi 👋 This is happening because The
So calling: res.body.getReader() will throw: TypeError: res.body.getReader is not a function If you are running on Node, you should either:
If you're expecting streaming behavior, make sure you're working with a Web-compatible runtime (e.g. edge / fetch API environment) instead of the Node adapter. Also note that a 204 response does not have a body, so This is expected behavior rather than a Hono bug 👍 |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Description
I encountered an issue with the
@hono/node-serverlibrary when attempting to access thegetReadermethod onres.body. The method is not available, resulting in the following error:TypeError: res.body.getReader is not a function at responseViaResponseObject (file:///home/pinna-marco-antonio/lili/back/node_modules/@hono/node-server/dist/index.mjs:420:29) at process.processTicksAndRejections (node:internal/process/task_queues:105:5) at async Server. (file:///home/pinna-marco-antonio/lili/back/node_modules/@hono/node-server/dist/index.mjs:551:14)
Code
Steps to Reproduce
Expected Behavior
The library should handle the
res.bodysafely, ensuring that the response body can be processed without errors, even if it is empty or not aReadableStream.Current Behavior
The
res.bodyobject does not have agetReadermethod, which causes the application to throw aTypeError.Possible Solution
To fix this issue, the
res.bodyshould be checked for the presence of thegetReadermethod before calling it. Here's an example solution:Beta Was this translation helpful? Give feedback.
All reactions