-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Accessing req.routeConfig in frameworkErrors handler throws TypeError #4807
Comments
If this is accepted as a valid issue, which requires a fix, I can work on a pull request. |
Yeah I think the getter should return undefined instead of throwing |
can I work on this issue ?? |
Go for it 👍 |
I looked at the code and figured that if either kRouteContext or kPublicRouteContext is undefined this will result in a TypeError at runtime, the req.routerPath is returning undefined |
It should be a matter of treating with care the returning statement. console.log(this[kRouteContext]?[kPublicRouteContext]); // Will return undefined if `kRouteContext` is undefined |
@sergburn I am having hard time Reproducing the Error can you please tell me where you wrote the above code. |
@ShivangRawat30 put it to |
console.log(this[kRouteContext][kPublicRouteContext]) //is undefined but when i logged
console.log(this[kRouteContext]) //it is logging [object, Object] which means an object is present in |
I provided a fix for this bug in #4826 |
That means that |
Prerequisites
Fastify version
4.17.0
Plugin version
No response
Node.js version
16.x
Operating system
macOS
Operating system version (i.e. 20.04, 11.3, 10)
11.7
Description
An attempt to get a value of
request.routeConfig
inframeworkErrors
handler throws an exception:Steps to Reproduce
Expected Behavior
Should return
undefined
as, for example,req.routerPath
doesThe text was updated successfully, but these errors were encountered: