What version of Elysia is running?
1.2.10
What platform is your computer?
Darwin 24.3.0 arm64 arm
What steps can reproduce the bug?
- Create an Elysia server using Node adapter with a
derive and a post. Use destructuring assignment with the body property from the Context.
import { node } from '@elysiajs/node';
import { Elysia } from 'elysia';
const app = new Elysia({ adapter: node() })
.onError(({ error }) => {
return error;
})
.derive(({ body }) => {
return {
operation: 'test'
};
})
.post(`/bug`, ({ operation }) => {
return operation;
})
.listen(3777);
- Run the server with Node.js and make an HTTP request to
POST /bug.
What is the expected behavior?
The expected behavior is to return "test' in the HTTP response, using the code above.
What do you see instead?
The onError handler will be caught with the error "Response body object should not be disturbed or locked".
Additional information
If you remove the destructuring assignment, the server responds normally.
import { node } from '@elysiajs/node';
import { Elysia } from 'elysia';
const app = new Elysia({ adapter: node() })
.onError(({ error }) => {
return error;
})
.derive((context) => {
return {
operation: 'test',
body2: context.body,
};
})
.post(`/bug`, ({ operation }) => {
return operation;
})
.listen(3777);
⚠ The body destructuring assignment is working normally running with Bun and without the Node adapter.
💡 Digging on the Web, I found this could be probably related to Fetch's Request body cloning. The destructuring assignment could be cloning the Request body without the proper .clone() call.
Have you try removing the node_modules and bun.lockb and try again yet?
Sure.
What version of Elysia is running?
1.2.10
What platform is your computer?
Darwin 24.3.0 arm64 arm
What steps can reproduce the bug?
deriveand apost. Use destructuring assignment with thebodyproperty from the Context.POST /bug.What is the expected behavior?
The expected behavior is to return "test' in the HTTP response, using the code above.
What do you see instead?
The
onErrorhandler will be caught with the error "Response body object should not be disturbed or locked".Additional information
If you remove the destructuring assignment, the server responds normally.
⚠ The
bodydestructuring assignment is working normally running with Bun and without the Node adapter.💡 Digging on the Web, I found this could be probably related to Fetch's Request body cloning. The destructuring assignment could be cloning the Request body without the proper
.clone()call.Have you try removing the
node_modulesandbun.lockband try again yet?Sure.