Home / Function/ onListenHookRunner() — fastify Function Reference

onListenHookRunner() — fastify Function Reference

Architecture documentation for the onListenHookRunner() function in hooks.js from the fastify codebase.

Entity Profile

Dependency Diagram

graph TD
  fbb9dc26_98c8_fef4_3a72_9e18e5fd4f9f["onListenHookRunner()"]
  57bfad3b_e85a_1ebf_2702_a13bb6484083["hooks.js"]
  fbb9dc26_98c8_fef4_3a72_9e18e5fd4f9f -->|defined in| 57bfad3b_e85a_1ebf_2702_a13bb6484083
  style fbb9dc26_98c8_fef4_3a72_9e18e5fd4f9f fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

lib/hooks.js lines 183–228

function onListenHookRunner (server) {
  const hooks = server[kHooks].onListen
  const hooksLen = hooks.length

  let i = 0
  let c = 0

  next()

  function next (err) {
    err && server.log.error(err)

    if (
      i === hooksLen
    ) {
      while (c < server[kChildren].length) {
        const child = server[kChildren][c++]
        onListenHookRunner(child)
      }
      return
    }

    wrap(hooks[i++], server, next)
  }

  async function wrap (fn, server, done) {
    if (fn.length === 1) {
      try {
        fn.call(server, done)
      } catch (e) {
        done(e)
      }
      return
    }
    try {
      const ret = fn.call(server)
      if (ret && typeof ret.then === 'function') {
        ret.then(done, done)
        return
      }
      done()
    } catch (error) {
      done(error)
    }
  }
}

Domain

Subdomains

Defined In

Frequently Asked Questions

What does onListenHookRunner() do?
onListenHookRunner() is a function in the fastify codebase, defined in lib/hooks.js.
Where is onListenHookRunner() defined?
onListenHookRunner() is defined in lib/hooks.js at line 183.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free