HonoH
Hono10mo ago
26 replies
Sébastien Morel

Invalid state: ReadableStream is already closed

Hello here,
I am starting to suspect something odd in @hono/node-server

We have random ReadableStream is already closed in the app, everything is try/catch but anyway it crashes the container.

We are also using GraphQL Yoga, I found out about this: https://github.com/honojs/node-server/issues/77

But I hesitate to do that because GraphQL Yoga is using @whatwg-node/fetch which is supposed to be a good abstraction.

the full trace is:

node:internal/webstreams/readablestream:1162
throw new ERR_INVALID_STATE.TypeError('ReadableStream is already closed');
^
TypeError [ERR_INVALID_STATE]: Invalid state: ReadableStream is already closed
at ReadableByteStreamController.close (node:internal/webstreams/readablestream:1162:13)
at node:internal/deps/undici/undici:1480:28
at node:internal/process/task_queues:151:7
at AsyncResource.runInAsyncScope (node:async_hooks:211:14)
at AsyncResource.runMicrotask (node:internal/process/task_queues:148:8)
at process.processTicksAndRejections (node:internal/process/task_queues:105:5) {
code: 'ERR_INVALID_STATE'
}
Node.js v22.13.1


Of course I don't reproduce easily, it happens randomly

Any idea? to identify the problem better?
Was this page helpful?