Skip to content

RouterPath deprecation warning when using Fastify integration on 404 #12844

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
3 tasks done
kingston opened this issue Jul 10, 2024 · 2 comments
Closed
3 tasks done

RouterPath deprecation warning when using Fastify integration on 404 #12844

kingston opened this issue Jul 10, 2024 · 2 comments

Comments

@kingston
Copy link

kingston commented Jul 10, 2024

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;
@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 3 Jul 10, 2024
@github-actions github-actions bot added the Package: node Issues related to the Sentry Node SDK label Jul 10, 2024
@lforst
Copy link
Member

lforst commented Jul 10, 2024

Hi, thanks for writing in. Feel free to open a PR! In case you don't end up doing so, please let us know so we can start fixing this. Thanks!

@mydea
Copy link
Member

mydea commented May 7, 2025

Closing as "duplicate" of #15542 which will solve this!

@mydea mydea closed this as completed May 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
5 participants