#How do you detect whether an http request has been aborted with Bun.serve?

1 messages · Page 1 of 1 (latest)

drifting flint
#

In node you can listen for the response "close" event, and check if .end() has been called.

Is there an equivilent for the bun http server?

clever burrow
#

You can use AbortSignal

drifting flint
#

Nice! Does it get passed into the fetch function?

clever burrow
drifting flint
#

Web standards, gotta love em.

#

While I'm here, is there a way to detect once the Response has been fully sent?

royal marlin
#

not sure
perhaps if youre using a ReadableStream, it will call the close handler on it
not 100% sure if this is called on socket end or simply "i read all the data"

drifting flint
#

Hmm. Basically I want to include bun sending the response in telemetry spans.

drifting flint