Open
Description
What version of Elysia is running?
^1.3.5
What platform is your computer?
Darwin 24.5.0 arm64 arm
What steps can reproduce the bug?
Follow the Node.js & pnpm quick start with typescript: Quick Start
brew install node
pnpm add elysia @elysiajs/node && \
pnpm add -D tsx @types/node typescript
Add swagger
pnpm add @elysiajs/swagger
Create src/index.ts
and add swagger.
import { Elysia } from 'elysia'
import { node } from '@elysiajs/node'
import { swagger } from '@elysiajs/swagger'
const app = new Elysia({ adapter: node() })
.use(swagger())
.get('/', () => 'Hello Elysia')
.listen(3000, ({ hostname, port }) => {
console.log(
`🦊 Elysia is running at ${hostname}:${port}`
)
})
package.json
{
"dependencies": {
"@elysiajs/node": "^1.3.0",
"@elysiajs/swagger": "^1.3.0",
"elysia": "^1.3.5"
},
"scripts": {
"dev": "tsx watch src/index.ts",
"build": "tsc src/index.ts --outDir dist",
"start": "NODE_ENV=production node dist/index.js"
},
"devDependencies": {
"@types/node": "^24.0.3",
"tsx": "^4.20.3",
"typescript": "^5.8.3"
}
}
Run:
pnpm dev
Bug
When accessing the Swagger interface at http://localhost:3000/swagger
, the expected interface initially loads correctly:
However, upon refreshing the page, the interface fails to load and the following issue occurs:
Terminal Output
🦊 Elysia is running at :::3000
TypeError: Body is unusable: Body has already been read
at consumeBody (node:internal/deps/undici/undici:5712:15)
at _Response.arrayBuffer (node:internal/deps/undici/undici:5657:18)
at responseViaResponseObject ([HIDDEN]/lab/elysia-try/node_modules/.pnpm/@hono+node-server@1.14.4_hono@4.8.1/node_modules/@hono/node-server/dist/index.js:436:32)
at Server.<anonymous> ([HIDDEN]/lab/elysia-try/node_modules/.pnpm/@hono+node-server@1.14.4_hono@4.8.1/node_modules/@hono/node-server/dist/index.js:492:20)
at Server.emit (node:events:524:28)
at parserOnIncoming (node:_http_server:1153:12)
at HTTPParser.parserOnHeadersComplete (node:_http_common:117:17)
TypeError: Body is unusable: Body has already been read
at consumeBody (node:internal/deps/undici/undici:5712:15)
at _Response.arrayBuffer (node:internal/deps/undici/undici:5657:18)
at responseViaResponseObject ([HIDDEN]/lab/elysia-try/node_modules/.pnpm/@hono+node-server@1.14.4_hono@4.8.1/node_modules/@hono/node-server/dist/index.js:436:32)
at Server.<anonymous> ([HIDDEN]/lab/elysia-try/node_modules/.pnpm/@hono+node-server@1.14.4_hono@4.8.1/node_modules/@hono/node-server/dist/index.js:492:20)
at Server.emit (node:events:524:28)
at parserOnIncoming (node:_http_server:1153:12)
at HTTPParser.parserOnHeadersComplete (node:_http_common:117:17)
TypeError: Body is unusable: Body has already been read
at consumeBody (node:internal/deps/undici/undici:5712:15)
at _Response.arrayBuffer (node:internal/deps/undici/undici:5657:18)
at responseViaResponseObject ([HIDDEN]/lab/elysia-try/node_modules/.pnpm/@hono+node-server@1.14.4_hono@4.8.1/node_modules/@hono/node-server/dist/index.js:436:32)
at Server.<anonymous> ([HIDDEN]/lab/elysia-try/node_modules/.pnpm/@hono+node-server@1.14.4_hono@4.8.1/node_modules/@hono/node-server/dist/index.js:492:20)
at Server.emit (node:events:524:28)
at parserOnIncoming (node:_http_server:1153:12)
at HTTPParser.parserOnHeadersComplete (node:_http_common:117:17)
TypeError: Body is unusable: Body has already been read
at consumeBody (node:internal/deps/undici/undici:5712:15)
at _Response.arrayBuffer (node:internal/deps/undici/undici:5657:18)
at responseViaResponseObject ([HIDDEN]/lab/elysia-try/node_modules/.pnpm/@hono+node-server@1.14.4_hono@4.8.1/node_modules/@hono/node-server/dist/index.js:436:32)
at Server.<anonymous> ([HIDDEN]/lab/elysia-try/node_modules/.pnpm/@hono+node-server@1.14.4_hono@4.8.1/node_modules/@hono/node-server/dist/index.js:492:20)
at Server.emit (node:events:524:28)
at parserOnIncoming (node:_http_server:1153:12)
at HTTPParser.parserOnHeadersComplete (node:_http_common:117:17)
TypeError: Body is unusable: Body has already been read
at consumeBody (node:internal/deps/undici/undici:5712:15)
at _Response.arrayBuffer (node:internal/deps/undici/undici:5657:18)
at responseViaResponseObject ([HIDDEN]/lab/elysia-try/node_modules/.pnpm/@hono+node-server@1.14.4_hono@4.8.1/node_modules/@hono/node-server/dist/index.js:436:32)
at Server.<anonymous> ([HIDDEN]/lab/elysia-try/node_modules/.pnpm/@hono+node-server@1.14.4_hono@4.8.1/node_modules/@hono/node-server/dist/index.js:492:20)
at Server.emit (node:events:524:28)
at parserOnIncoming (node:_http_server:1153:12)
at HTTPParser.parserOnHeadersComplete (node:_http_common:117:17)
What is the expected behavior?
Be able to reload the swagger's page without raising an error
What do you see instead?
An error: Error: Body is unusable: Body has already been read
Additional information
When I remove the { adapter: node() }
from Elysia and use bun it works fine...
Have you try removing the node_modules
and bun.lockb
and try again yet?
Yes