Skip to content

tracingPlugin doesn't wrap route handlers registered via ~findRoute #4211

@logaretm

Description

@logaretm

When a framework (e.g. nitro) uses a custom ~findRoute function instead of registering routes via h3["~routes"] or h3.on(), the tracingPlugin never wraps those route handlers with wrapEventHandler.

The plugin currently wraps routes in three places:

  1. Iterating h3["~routes"] at registration time (line 30)
  2. Patching h3.on() for future routes (line 37)
  3. Patching h3.use() for middleware (line 49)

But nitro sets h3["~findRoute"] directly (bypassing ~routes entirely) to resolve file-based routes at request time. Since the plugin never intercepts ~findRoute, those route handlers are never wrapped, so no h3.request tracing channel event with type: "route" is ever emitted.

Middleware tracing works fine because nitro pushes global middleware to h3["~middleware"], which the plugin does wrap.

Expected behavior:
A request to a nitro file-based route should emit both a middleware span (type: "middleware") and a route handler span (type: "route").

Actual behavior:
Only middleware spans are emitted. The route handler executes untraced by h3.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions