Skip to content
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

FastifyDeprecation: Request#context property access is deprecated. Please use "Request#routeConfig" or "Request#routeSchema" instead for accessing Route settings. The "Request#context" will be removed in fastify@5. #1275

Open
stefee opened this issue Nov 8, 2022 · 25 comments
Labels
bug Something isn't working pkg:instrumentation-fastify priority:p4 Bugs and spec inconsistencies which do not fall into a higher prioritization up-for-grabs Good for taking. Extra help will be provided by maintainers

Comments

@stefee
Copy link

stefee commented Nov 8, 2022

What version of OpenTelemetry are you using?

@opentelemetry/instrumentation-fastify@0.30.1

What version of Node are you using?

v16.14.2

What did you do?

Node auto instrumentation on a Fastify application

What did you expect to see?

No deprecation notices

What did you see instead?

FastifyDeprecation: Request#context property access is deprecated. Please use "Request#routeConfig" or "Request#routeSchema" instead for accessing Route settings. The "Request#context" will be removed in `fastify@5`.

Additional context

Request .context is used here:

const requestContext = (request as any).context || {};

@stefee stefee added the bug Something isn't working label Nov 8, 2022
@dyladan dyladan added up-for-grabs Good for taking. Extra help will be provided by maintainers priority:p4 Bugs and spec inconsistencies which do not fall into a higher prioritization labels Nov 9, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Jan 9, 2023

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 14 days.

@github-actions github-actions bot added the stale label Jan 9, 2023
@stefee
Copy link
Author

stefee commented Jan 9, 2023

Bump

@github-actions github-actions bot removed the stale label Jan 16, 2023
@github-actions
Copy link
Contributor

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 14 days.

@github-actions github-actions bot added the stale label Mar 20, 2023
@SimenB
Copy link
Contributor

SimenB commented Mar 20, 2023

PR is incoming in fastify: fastify/fastify#4470

@Bruno-DaSilva
Copy link

bump :(

@Uzlopak
Copy link

Uzlopak commented Aug 6, 2023

To fix the issue in opentelemetry, you would need to patch

const requestContext = (request as any).context || {};

There I think you would need to change it to:

      const handlerName = (((request as any).routeConfig || {})?.name || '').substr(6);

@Uzlopak
Copy link

Uzlopak commented Aug 6, 2023

Or maybe even simpler:

      const handlerName = (request as any)?.routeConfig?.name?.substr(6) || '';

I did not test it.

@freakyfelt
Copy link

Alas that one won't work as the routeConfig does not expose the handler, so we're waiting for fastify/fastify#4470

@Uzlopak
Copy link

Uzlopak commented Aug 21, 2023

I closed the remaining issues in the fastify PR and requested review by @Eomm

@drewcorlin1
Copy link
Contributor

Wouldn't this be the most type safe way to fix the warning?

const handlerName = `${request.routeOptions.method} ${request.routeOptions.url}`;

@freakyfelt
Copy link

Wouldn't this be the most type safe way to fix the warning?

This particular label is for the name of the handler (e.g. the name of the function), so changing it would be a breaking a change

@SimenB
Copy link
Contributor

SimenB commented Sep 4, 2023

Change in Fastify landed now (:tada:), so once that's released it's hopefully not too difficult to migrate the instrumentation.

This particular label is for the name of the handler (e.g. the name of the function), so changing it would be a breaking a change

The instrumentation is experimental (v0.x), so I don't think that's a huge concern? Not sure how these things are managed.

@Travispersson
Copy link

Change in Fastify landed now (🎉), so once that's released it's hopefully not too difficult to migrate the instrumentation.

This particular label is for the name of the handler (e.g. the name of the function), so changing it would be a breaking a change

The instrumentation is experimental (v0.x), so I don't think that's a huge concern? Not sure how these things are managed.

It's now available in the latest Fastify release that was released today 🥳

@Travispersson
Copy link

Travispersson commented Sep 13, 2023

Hmm, just a note, I'm getting these deprecation warnings as well from this instrumentation lib

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

Could be this line?

edit: I see that the PR linked to this issue is addressing that though, nice! 💯

@Uzlopak
Copy link

Uzlopak commented Sep 13, 2023

yes

@mateus4k
Copy link

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

Is there any PR updating this?

@Travispersson
Copy link

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

Is there any PR updating this?

#1679
Yep a fix was released ⭐

@mateus4k
Copy link

Thanks, @Travispersson!

@omBratteng
Copy link

Still getting this error

(node:9) [FSTDEP017] FastifyDeprecation: You are accessing the deprecated "request.routerPath" property. Use "request.routeOptions.url" instead. Property "req.routerPath" will be removed in `fastify@5`.

We are using the latest version of the intrumentation

https://github.com/dailydotdev/daily-api/blob/dc3bbecd7c04984a60a224b19ae9752102caf09e/package.json#L48

and version 4.24.2 of fastify

https://github.com/dailydotdev/daily-api/blob/dc3bbecd7c04984a60a224b19ae9752102caf09e/package.json#L71

@omBratteng
Copy link

So digging a bit further into it, I think it might when the requests are to not found pages. but then both request.routeOptions.url and request.routerPath are undefined.

@Wazbat
Copy link

Wazbat commented Oct 29, 2023

I can confirm that I'm also still getting these errors

(node:1) [FSTDEP017] FastifyDeprecation: You are accessing the deprecated "request.routerPath" property. Use "request.routeOptions.url" instead. Property "req.routerPath" will be removed in `fastify@5`.

fastify 4.24.3 and @opentelemetry/instrumentation-fastify 0.32.3

@SimenB
Copy link
Contributor

SimenB commented Oct 29, 2023

That's separate from the one in the OP (which hss been fixed, from what I can tell). Might be worth its own issue? Or just somebody sending a PR 🙂

@omBratteng
Copy link

I've split it into a separate issue here #1757

@trentm
Copy link
Contributor

trentm commented Nov 1, 2023

I believe this was fixed in #1679, when one is using fastify >=4.23.0 (when the request.routeOptions.handler option was made available). When using earlier fastify versions there is nothing the instrumentation can do to avoid the deprecation warning.

I have a PR up for the separate #1757 issue.

@trentm
Copy link
Contributor

trentm commented Nov 1, 2023

I believe this was fixed in #1679,

^ @pichlermarc I think you can close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working pkg:instrumentation-fastify priority:p4 Bugs and spec inconsistencies which do not fall into a higher prioritization up-for-grabs Good for taking. Extra help will be provided by maintainers
Projects
None yet
Development

No branches or pull requests