Skip to content

RouterPath deprecation warning when using Fastify integration on 404 #12844

Closed as duplicate
@kingston

Description

@kingston

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/node

SDK Version

8.16.0

Framework Version

Fastify 4.25.2

Link to Sentry event

No response

SDK Setup/Reproduction Example

import './instrument.ts';
import Fastify from "fastify";
import * as Sentry from "@sentry/node";

const app = Fastify();

Sentry.setupFastifyErrorHandler(app);

app.listen({ port: 3030 });

Steps to Reproduce

  1. Set up a standard Fastify server with Fastify tracing
  2. Access a 404 route that does not exist

Expected Result

No deprecation warnings

Actual Result

The following warning:

[FSTDEP017] DeprecationWarning: You are accessing the deprecated "request.routerPath" property. Use "request.routeOptions.url" instead. Property "req.routerPath" will be removed in fastify@5.

Caused by this line of code: const routeName = reqWithRouteInfo.routeOptions?.url || reqWithRouteInfo.routerPath;

In 404 errors, routeOptions?.url is undefined so it falls back to routerPath which is deprecated. The OpenTelemetry code that this line was based on has already been fixed in this PR (open-telemetry/opentelemetry-js-contrib@18ae75c#diff-b4262d2d3aefe5f35cfe70e34be5b0bd7324b1623cec94fdf8d2253c9cf9db89R281). Should be a fairly trivial fix - happy to submit a PR as well but not sure what's the best way forward so filing an issue first.

const routeName = reqWithRouteInfo.routeOptions ? reqWithRouteInfo.routeOptions.url : reqWithRouteInfo.routerPath;

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions