node-server icon indicating copy to clipboard operation
node-server copied to clipboard

SSE fetch gets cancelled => Hono Node server prints an error on console

Open ukstv opened this issue 1 year ago • 1 comments

Disposition:

  1. There is a Hono server, with a POST endpoint replying with Server-Sent Events
  2. The response is consumed through fetch().response.body.getReader() Reader
  3. Either (a) the reader cancels via reader.cancel(),
  4. Or (b) fetch AbortSignal gets aborted

Expectation: things are working well Reality:

  • Node.js reports an error: TypeError: Response body object should not be disturbed or locked :(
  • You can not catch the error :(( It is just on console

The reproduction repository is on https://github.com/ukstv/hono-sse-repro

The error is from Readable.toWeb(incoming) line. It fails because incoming is "disturbed". That is kind of expected though, as the request got aborted.

ukstv avatar Jun 20 '24 14:06 ukstv

Hi @ukstv

Sorry for the late reply. This maybe fixed the latest version. Can you try it?

yusukebe avatar Jul 18 '24 10:07 yusukebe

@yusukebe It works! Thank you!

ukstv avatar Aug 11 '24 10:08 ukstv