-
-
Notifications
You must be signed in to change notification settings - Fork 11
Open
Labels
bugSomething isn't workingSomething isn't workingquestionFurther information is requestedFurther information is requested
Description
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
deriveand apost. Use destructuring assignment with thebodyproperty 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.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingquestionFurther information is requestedFurther information is requested