MCPcopy
hub / github.com/fastify/fastify / onRequestAbortHookRunner

Function onRequestAbortHookRunner

lib/hooks.js:370–404  ·  view source on GitHub ↗
(functions, request, cb)

Source from the content-addressed store, hash-verified

368}
369
370function onRequestAbortHookRunner (functions, request, cb) {
371 let i = 0
372
373 function next (err) {
374 if (err || i === functions.length) {
375 cb(err, request)
376 return
377 }
378
379 let result
380 try {
381 result = functions[i++](request, next)
382 } catch (error) {
383 cb(error, request)
384 return
385 }
386 if (result && typeof result.then === 'function') {
387 result.then(handleResolve, handleReject)
388 }
389 }
390
391 function handleResolve () {
392 next()
393 }
394
395 function handleReject (err) {
396 if (!err) {
397 err = new FST_ERR_SEND_UNDEFINED_ERR()
398 }
399
400 cb(err, request)
401 }
402
403 next()
404}
405
406function hookIterator (fn, request, reply, next) {
407 if (reply.sent === true) return undefined

Callers 1

routeHandlerFunction · 0.85

Calls 1

nextFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…