# Behavior traces — fastify/fastify

> Canonical page: https://codevetter.com/unpack/fastify/behavior-traces

# Behavior traces — fastify/fastify

Scanned commit 19d5be0daf1c0daace758efe3ea788f924ca1224 (2026-09-29). Generated by codevetter codevetter 1.15.0 on 2026-10-02.

Source inspection; upstream code and tests were not executed.

Three concrete core flows were followed through source: startup and listening, request handling and reply serialization, and shutdown. Injection provides another entry into the same handler after readiness. The database write example illustrates an application-owned persistence boundary rather than an implemented core store. These are source traces, not runtime observations.
- Startup begins fastify() → processOptions → buildRouting/build404 → wrapRouting → createServer → SchemaController construction. — [fastify.js#L89-117](https://github.com/fastify/fastify/blob/19d5be0daf1c0daace758efe3ea788f924ca1224/fastify.js#L89-L117)
- Plugin boot installs Avvio → override; override calls registerPlugin, then either reuses the parent or constructs an inherited child with copied scoped facilities. — [fastify.js#L367-379](https://github.com/fastify/fastify/blob/19d5be0daf1c0daace758efe3ea788f924ca1224/fastify.js#L367-L379) [lib/plugin-override.js#L28-50](https://github.com/fastify/fastify/blob/19d5be0daf1c0daace758efe3ea788f924ca1224/lib/plugin-override.js#L28-L50)
- Promise listening follows listen → listenPromise → ready → transport server.listen; success resolves a logged address. — [lib/server.js#L105-123](https://github.com/fastify/fastify/blob/19d5be0daf1c0daace758efe3ea788f924ca1224/lib/server.js#L105-L123) [lib/server.js#L267-304](https://github.com/fastify/fastify/blob/19d5be0daf1c0daace758efe3ea788f924ca1224/lib/server.js#L267-L304)
- For localhost, listening continues through multipleBindings → dns.lookup → additional server instances → onListenHookRunner. — [lib/server.js#L105-118](https://github.com/fastify/fastify/blob/19d5be0daf1c0daace758efe3ea788f924ca1224/lib/server.js#L105-L118) [lib/server.js#L150-189](https://github.com/fastify/fastify/blob/19d5be0daf1c0daace758efe3ea788f924ca1224/lib/server.js#L150-L189)
- Request handling follows routeHandler → Request/Reply creation → onRequestHookRunner → runPreParsing → handleRequest. — [lib/route.js#L526-529](https://github.com/fastify/fastify/blob/19d5be0daf1c0daace758efe3ea788f924ca1224/lib/route.js#L526-L529) [lib/route.js#L567-576](https://github.com/fastify/fastify/blob/19d5be0daf1c0daace758efe3ea788f924ca1224/lib/route.js#L567-L576) [lib/route.js#L651-665](https://github.com/fastify/fastify/blob/19d5be0daf1c0daace758efe3ea788f924ca1224/lib/route.js#L651-L665)
- After parsing, handler → preValidationCallback → validateSchema → validationCompleted → preHandlerCallback → context.handler; results use wrapThenable or reply.send. — [lib/handle-request.js#L89-145](https://github.com/fastify/fastify/blob/19d5be0daf1c0daace758efe3ea788f924ca1224/lib/handle-request.js#L89-L145) [lib/handle-request.js#L171-209](https://github.com/fastify/fastify/blob/19d5be0daf1c0daace758efe3ea788f924ca1224/lib/handle-request.js#L171-L209)
- Object reply serialization follows preSerializationHook → preSerializationHookEnd → serializer selection → onSendHook → onSendEnd. — [lib/reply.js#L520-555](https://github.com/fastify/fastify/blob/19d5be0daf1c0daace758efe3ea788f924ca1224/lib/reply.js#L520-L555) [lib/reply.js#L561-580](https://github.com/fastify/fastify/blob/19d5be0daf1c0daace758efe3ea788f924ca1224/lib/reply.js#L561-L580)
- Error sending enters onErrorHook; handleError selects the current or next inherited error handler, invokes it, and falls back to serialized transport output. — [lib/reply.js#L156-169](https://github.com/fastify/fastify/blob/19d5be0daf1c0daace758efe3ea788f924ca1224/lib/reply.js#L156-L169) [lib/error-handler.js#L30-75](https://github.com/fastify/fastify/blob/19d5be0daf1c0daace758efe3ea788f924ca1224/lib/error-handler.js#L30-L75) [lib/error-handler.js#L85-121](https://github.com/fastify/fastify/blob/19d5be0daf1c0daace758efe3ea788f924ca1224/lib/error-handler.js#L85-L121)
- Shutdown marks closing, closes routes, runs preClose, handles configured forced socket closure and available HTTP/2 session cleanup, then calls server.close unless an unstarted custom serverFactory instance takes the nextTick completion branch. — [fastify.js#L383-428](https://github.com/fastify/fastify/blob/19d5be0daf1c0daace758efe3ea788f924ca1224/fastify.js#L383-L428)
- The documented persistence flow is register Redis plugin → POST /foo → redis.set(req.body.key, req.body.value) → completion reply; it is an example integration. — [docs/Guides/Database.md#L81-103](https://github.com/fastify/fastify/blob/19d5be0daf1c0daace758efe3ea788f924ca1224/docs/Guides/Database.md#L81-L103)

Every claim links to its cited files at the pinned commit. Citations identify source evidence; they do not establish runtime correctness. Independent CodeVetter scan — not reviewed by upstream maintainers.

## Public product links

- [CodeVetter](https://codevetter.com/)
- [Download](https://codevetter.com/download)
- [Documentation](https://codevetter.com/docs/)
- [Source](https://github.com/Codevetter/codevetter)
