# Behavior traces — elysiajs/elysia

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

# Behavior traces — elysiajs/elysia

Scanned commit e037eca710e7ad193be09cc6615ab0dbe54af914 (2026-08-26). Generated by codevetter codevetter 1.15.0 on 2026-10-02.

Source inspection; upstream code and tests were not executed.

The inspected flows cover server startup, request validation and cookie persistence across HTTP boundaries. Additional traces follow shared counter state, native constant responses, WebSockets and file ranges. Execution order includes early returns and adapter-specific conditions. These walkthroughs describe source behavior and test intent; they are not recorded runtime executions.
- Startup: example/counter constructs Elysia, calls state then get, and listen delegates to BunAdapter.listen; that calls compile, builds serving options, invokes Bun.serve, then start hooks and the callback. — [example/counter.ts#L1-6](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/example/counter.ts#L1-L6) [src/index.ts#L8161-8167](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/index.ts#L8161-L8167) [src/adapter/bun/index.ts#L222-235](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/adapter/bun/index.ts#L222-L235) [src/adapter/bun/index.ts#L360-396](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/adapter/bun/index.ts#L360-L396)
- AOT first request: handle accesses fetch, composeGeneralHandler builds dispatch and installs the error handler, request hooks precede routing, and a route's lazy compile closure calls composeHandler and caches its result. — [src/index.ts#L8092-8110](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/index.ts#L8092-L8110) [src/compose.ts#L2531-2557](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/compose.ts#L2531-L2557) [src/index.ts#L918-964](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/index.ts#L918-L964)
- Dynamic POST: createDynamicHandler constructs context, runs request hooks, finds the route, parses JSON, runs transform hooks, validates body, runs beforeHandle, invokes handle and maps its response. — [src/dynamic-handle.ts#L214-290](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/dynamic-handle.ts#L214-L290) [src/dynamic-handle.ts#L549-565](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/dynamic-handle.ts#L549-L565) [src/dynamic-handle.ts#L672-738](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/dynamic-handle.ts#L672-L738) [src/dynamic-handle.ts#L922-935](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/dynamic-handle.ts#L922-L935)
- Invalid-input branch: validateStandardSchema awaits Validate and throws on issues; dynamic dispatch catches the error and delegates to handleError, whose dynamic implementation runs error hooks before its status/message fallback. — [src/dynamic-handle.ts#L189-205](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/dynamic-handle.ts#L189-L205) [src/dynamic-handle.ts#L924-935](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/dynamic-handle.ts#L924-L935) [src/dynamic-handle.ts#L987-1016](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/dynamic-handle.ts#L987-L1016) [src/error.ts#L312-314](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/error.ts#L312-L314)
- Cookie persistence: the /create example assigns name.value; the jar records outgoing changes, AOT encodeCookie signs selected cookies with the first configured key, handleSet serializes them, and later parseCookie verifies keys before decoding values. — [example/cookie.ts#L29-43](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/example/cookie.ts#L29-L43) [src/cookies.ts#L160-187](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/cookies.ts#L160-L187) [src/compose.ts#L630-651](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/compose.ts#L630-L651) [src/cookies.ts#L403-453](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/cookies.ts#L403-L453)
- Shared counter: state('counter', 0) populates singleton.store, createContext passes that same store into the request, and the GET handler returns the previous counter value while incrementing it in memory. — [example/counter.ts#L3-6](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/example/counter.ts#L3-L6) [src/index.ts#L7136-7140](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/index.ts#L7136-L7140) [src/adapter/web-standard/index.ts#L169-183](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/adapter/web-standard/index.ts#L169-L183)
- Native constant response: add asks createNativeStaticHandler for a literal handler, that helper rejects nonempty pipeline hooks, and BunAdapter refuses native static route assembly when request hooks, tracing or higher-order wrappers exist. — [src/index.ts#L873-911](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/index.ts#L873-L911) [src/adapter/bun/handler-native.ts#L7-43](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/adapter/bun/handler-native.ts#L7-L43) [src/adapter/bun/index.ts#L264-272](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/adapter/bun/index.ts#L264-L272)
- File range request: mapResponse dispatches Blob/File to handleFile; a bytes range is parsed and clamped, invalid positions return 416, and valid positions produce a sliced 206 response with range/length headers. — [src/adapter/web-standard/handler.ts#L74-81](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/adapter/web-standard/handler.ts#L74-L81) [src/adapter/utils.ts#L19-80](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/adapter/utils.ts#L19-L80) [test/response/range.test.ts#L18-70](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/test/response/range.test.ts#L18-L70)

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)
