Skip to content

Fix Hono response body locked error#503

Merged
hansott merged 7 commits intomainfrom
fix-hono-body-locked
Jan 20, 2025
Merged

Fix Hono response body locked error#503
hansott merged 7 commits intomainfrom
fix-hono-body-locked

Conversation

@timokoessler
Copy link
Member

@timokoessler timokoessler commented Jan 20, 2025

TypeError: Response body object should not be disturbed or locked
at extractBody (node:internal/deps/undici/undici:5567:17)
at new Request (node:internal/deps/undici/undici:9783:48)
at new Request (/app/node_modules/@hono/node-server/dist/index.js:68:5)
at proxyRequest (/app/routes/api/oauth.js:42:5)
at /app/routes/api/oauth.js:69:20
at /app/node_modules/@aikidosec/firewall/sources/hono/wrapRequestHandler.js:10:26
at runWithContext (/app/node_modules/@aikidosec/firewall/agent/Context.js:56:16)
at /app/node_modules/@aikidosec/firewall/sources/hono/wrapRequestHandler.js:9:51
at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
at async dispatch (/app/node_modules/hono/dist/cjs/compose.js:52:17)

https://hono.dev/examples/proxy

@codecov
Copy link

codecov bot commented Jan 20, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

📢 Thoughts on this report? Let us know!

@timokoessler timokoessler marked this pull request as ready for review January 20, 2025 10:24
export function wrapRequestBodyParsing(req: Context["req"]) {
req.parseBody = wrapBodyParsingFunction(req.parseBody);
req.json = wrapBodyParsingFunction(req.json);
req.text = wrapBodyParsingFunction(req.text);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add a test for when this function throws?

@hansott hansott merged commit 1402d3d into main Jan 20, 2025
11 checks passed
@hansott hansott deleted the fix-hono-body-locked branch January 20, 2025 17:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants