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

feat: disable rate limiter in test #6146

Merged
merged 2 commits into from
Mar 22, 2022

Conversation

blimmer
Copy link
Contributor

@blimmer blimmer commented Mar 1, 2022

This PR supersedes #6063. Instead of choosing between a StubRateLimiter and an InMemoryRateLimiter, we just disable it when NODE_ENV is test. See https://github.com/ParabolInc/parabol/pull/6063/files#r814362740 for details.

Relates to #6018

scheduleGc?: boolean
}

export class InMemoryRateLimiter {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I retained some of the changes I made in the original PR so I could just port over the unit test directly.


let rateLimiter: RateLimiter
let rateLimiter: InMemoryRateLimiter
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found the name InMemoryRateLimiter a bit clearer, but I can change this back to just RateLimiter if you'd like.

@@ -14,39 +14,38 @@ interface Options {
perHour: number
}

const rateLimit = <TSource = any, TContext = GQLContext, TArgs = any>({
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prettier rewrote a bunch of this, I called out the actual change below.

Comment on lines +27 to +29
if (process.env.NODE_ENV === 'test') {
return
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the only change - the requested if statement to disable in test.

@blimmer blimmer marked this pull request as ready for review March 1, 2022 22:10
@blimmer blimmer requested a review from mattkrick March 1, 2022 22:10
@mattkrick
Copy link
Member

LGTM!

@mattkrick mattkrick merged commit f7da667 into master Mar 22, 2022
@mattkrick mattkrick deleted the feature/disable-rate-limiter-in-test branch March 22, 2022 17:33
@adaniels-parabol adaniels-parabol mentioned this pull request Mar 25, 2022
16 tasks
@github-actions github-actions bot mentioned this pull request Sep 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

3 participants