MCPcopy
hub / github.com/fastify/fastify / safeWriteHead

Function safeWriteHead

lib/reply.js:565–575  ·  view source on GitHub ↗
(reply, statusCode)

Source from the content-addressed store, hash-verified

563}
564
565function safeWriteHead (reply, statusCode) {
566 const res = reply.raw
567 try {
568 res.writeHead(statusCode, reply[kReplyHeaders])
569 } catch (err) {
570 if (err.code === 'ERR_HTTP_HEADERS_SENT') {
571 reply.log.warn(`Reply was already sent, did you forget to "return reply" in the "${reply.request.raw.url}" (${reply.request.raw.method}) route?`)
572 }
573 throw err
574 }
575}
576
577function onSendEnd (reply, payload) {
578 const res = reply.raw

Callers 1

onSendEndFunction · 0.85

Calls 1

warnMethod · 0.80

Tested by

no test coverage detected