-
-
Notifications
You must be signed in to change notification settings - Fork 578
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
TypeError: Response body object should not be disturbed or locked #1695
Comments
Hi @RobertSasak, Thank you for creating this. Since it's an issue with |
Originaly I tested on 1.2.0. I have updated to 1.2.2 just now and the issue still occurs. |
I'm having this issue as well. Seems to have to do with that Tested on Node 18.17.1, hono 3.10.2, @hono/node-server 1.2.3. |
The above workaround doesn't seem to work in my case. The |
any head-way on this? |
c.req.json() and c.req.valid("json") don't work and make it almost unusable. |
Is there an update to this? Looks like this might be related to: vercel/next.js#50166 and FirebaseExtended/firebase-framework-tools#122 |
I had this identical issue with using vercel funcitons. I found a solution that might help you further debug the problem. A similar issue highlights the code in the vercel dev serve that causese the issue: The issue can be resolved by setting the following environment variable in your local environment file:
It might be worth checking if Firebase Functions has similar behaviour |
Hi. Is this problem still happening? I don't have an environment for Firebase. If it's not resolved, I'll make it and try to investigate. |
This problem still happens when you cancel a request that is in progress |
has the exact same error using npm - 10.5.0, "vercel": "^35.2.3", "hono": "^4.5.1", "@hono/node-server": "^1.12.0", |
using npm i vercel@latest and "@hono/node-server/vercel" - any request to the hono server ends up with Error occurs if request contains payload, in my case simple json. @yusukebe Is it hono problem or vercel problem? NODEJS_HELPERS=0 not helping |
I also noticed that if i turn off cors middleware, and the post route looks like this:
Everything works. But as soon as I turn on cors - I get the error: "Response body object should not be disturbed or locked". |
@yusukebe As I see, no responses in this thread. Does it mean, that HonoJs is just not compatible with Vercel's node js environment? And there is no point in waiting for the fast solution and better to move to another framework?
|
Sorry for the lack of response. If you can share a minimal repo to reproduce it, I can investigate. |
@yusukebe I removed vercel info and node modules. Request I'm sending from svelte application using this code (using hono RPC):
Thank you very much for your help @yusukebe P.S. Error itself: |
I've tried it, but I can't understand how to reproduce it. And this project is not minimal. I'm sorry, but I can't help you. |
@yusukebe What does it mean you can't reproduce it? I tried it using macbook M2 air, I tried it using windows 10 machine. Always the same result. I even installed Thunder Client in VS Code to make requests without svelte client. And the result is always the same: Is it really working for you? Exactly the same request in Thunder client, working perfectly using NestJS. May be you need some more data? |
Hi @Bobetti Sorry, it is reproduced. This is a Vercel matter. The stream of |
@yusukebe thank you very much for your help. |
We're hitting this same issue (we do not use vercel or other middleware that adds helpers). It seems specific to sockets getting closed while the request handler is still trying to fulfill the request. Specifically canceling existing requests leads to this bug:
This is running in docker on linux. |
Hi @maxweisel Can you provide a minimal project to reproduce it? It's better it work on my MacOS machine(not on docker) if possible. |
Also experiencing this when functions are deployed to google functions. import { getRequestListener } from '@hono/node-server';
import { http } from '@google-cloud/functions-framework';
import { app } from './app';
http('handler', getRequestListener(app.fetch)); With the following code, any post is not working when deployed to google functions (gen2). |
Update: Set
I have the same issue on Vercel, there are some test cases to reproduce it. ✅ Do nothingapp.post("/debug", (c) => {
return c.json({});
}); ✅ Print contextapp.post("/debug", (c) => {
console.log(c);
return c.json({});
}); ❌ Print requestapp.post("/debug", (c) => {
console.log(c.req);
return c.json({});
});
✅ Use
|
Hi, @yusukebe! I'm having a similar issue while using hono and deploying to firebase functions. Any help would be appreciated! |
What version of Hono are you using?
3.9.0
What runtime/platform is your app running on?
Firebase functions
What steps can reproduce the bug?
Here is a simple example with POST end point.
What is the expected behavior?
Requst should reach Heno and Hello World should appear.
What do you see instead?
There is an following silent error 500 when doing a POST request with payload. By placing an console.log in https://github.com/honojs/node-server/blob/3575d60a15e345700b81e22376825e98b0a69ebe/src/listener.ts#L42 it is possible to see this error.
Additional information
Similar issue is documented here honojs/node-server#84
As far as I understand the issue occurs in https://github.com/honojs/node-server/blob/3575d60a15e345700b81e22376825e98b0a69ebe/src/listener.ts#L40 . Here the new Request is created from incoming request.
Firebase use expressjs to process all request and also expose Express JS Request object as an incoming. However this request is already "processed" and the actual body stream is already read.
So when on line https://github.com/honojs/node-server/blob/3575d60a15e345700b81e22376825e98b0a69ebe/src/listener.ts#L38 the read stream is create there is nothing to read.
I am not sure if this is an issue of Hono or how to approach it.
My workaround is to patch listner file and restore body from rawBody.
The text was updated successfully, but these errors were encountered: