MCPcopy Create free account
hub / github.com/fastify/fastify / buildAsyncConstraintCallback

Function buildAsyncConstraintCallback

fastify.js:690–713  ·  view source on GitHub ↗
(isAsync, req, res)

Source from the content-addressed store, hash-verified

688 }
689
690 function buildAsyncConstraintCallback (isAsync, req, res) {
691 if (isAsync === false) return undefined
692 return function onAsyncConstraintError (err) {
693 if (err) {
694 if (options.frameworkErrors) {
695 const id = getGenReqId(routeEventContext.server, req)
696 const childLogger = createChildLogger(routeEventContext, options.logger, req, id)
697
698 const request = new Request(id, null, req, null, childLogger, routeEventContext)
699 const reply = new Reply(res, request, childLogger)
700
701 routeEventContext.server[kLogController].incomingRequest(request, reply)
702
703 return options.frameworkErrors(new FST_ERR_ASYNC_CONSTRAINT(), request, reply)
704 }
705 const body = '{"error":"Internal Server Error","message":"Unexpected error from async constraint","statusCode":500}'
706 res.writeHead(500, {
707 'Content-Type': 'application/json',
708 'Content-Length': body.length
709 })
710 res.end(body)
711 }
712 }
713 }
714
715 function setNotFoundHandler (opts, handler) {
716 throwIfAlreadyStarted('Cannot call "setNotFoundHandler"!')

Callers 1

wrapRoutingFunction · 0.85

Calls 3

getGenReqIdFunction · 0.85
createChildLoggerFunction · 0.85
incomingRequestMethod · 0.45

Tested by

no test coverage detected