-
-
Notifications
You must be signed in to change notification settings - Fork 62
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
eslint no-misused-promise in notFoundHandler #355
Comments
Fastify normalizes the flow between promises and non-promisified code. Essentially that rule is too strict for no specific reason. To solve, just add a
or return it:
|
Ah it might be a bug in our types. That does not return a promise. That returns a function that returns a promise. |
Would you like to send a PR? |
Yea that was my assumption. Can have a look into this later. |
I am not sure how to fix this. |
Can you share a reproduction for this? So somebody can quickly work for a resolution. |
See 'Steps to reproduce' in Original Post. What else would you need to reproduce? |
We often need a reproducible example, e.g. some code that allows someone else to recreate your problem by just copying and pasting it. If it involves more than a couple of different file, create a new repository on GitHub and add a link to that. TL;DR Set up a tiny repository that shows the problem. |
app.ts:
package.json
tsconfig.json
.eslintrc.js
Steps to reproduce:
Actual output:
Expected output:
|
I think you got your file names wrong. I recommend you to upload everything to a repository. |
Sorry, accidentally hit save before I was ready. |
Running |
updated repo. pls try again |
Thanks, that was helpful. Here is the fix: fastify/fastify#5258 |
Awesome, thanks for fixing! |
Prerequisites
Fastify version
4.25.2
Plugin version
9.0.1
Node.js version
20.10.0
Operating system
Linux
Operating system version (i.e. 20.04, 11.3, 10)
Description
I am rate limiting 404 errors as documented here:
https://github.com/fastify/fastify-rate-limit#preventing-guessing-of-urls-through-404s
notFoundHandler
expects apreValidationHookHandler
, butfastify.rateLimit()
is apreHandlerAsyncHookHandler
Steps to Reproduce
Use
no-misused-promise
eslint ruleExpected Behavior
No erorrs / warnings thrown
The text was updated successfully, but these errors were encountered: