MCPcopy
hub / github.com/fastify/fastify / onRead

Function onRead

lib/reply.js:768–787  ·  view source on GitHub ↗
(result)

Source from the content-addressed store, hash-verified

766 }
767
768 function onRead (result) {
769 if (result.done) {
770 sourceOpen = false
771 sendTrailer(null, res, reply)
772 return
773 }
774 /* c8 ignore next 5 - race condition: eos handler typically fires first */
775 if (res.destroyed) {
776 sourceOpen = false
777 reader.cancel().catch(noop)
778 return
779 }
780 const shouldContinue = res.write(result.value)
781 if (shouldContinue === false) {
782 waitingDrain = true
783 res.once('drain', onDrain)
784 return
785 }
786 reader.read().then(onRead, onReadError)
787 }
788
789 function onDrain () {
790 if (!waitingDrain || !sourceOpen || res.destroyed) {

Callers

nothing calls this directly

Calls 3

sendTrailerFunction · 0.85
writeMethod · 0.80
thenMethod · 0.80

Tested by

no test coverage detected