RateLimiterQueue default params #340
Merged
animir merged 5 commits intoanimir:masterfrom Dec 13, 2025
Merged
Conversation
…or maxQueueSize and key
…or maxQueueSize and key
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a bug where passing an empty options object {} to RateLimiterQueue caused maxQueueSize to be undefined, leading to runtime errors. The fix implements proper fallback logic for default parameters and adds TypeScript constraints.
Key Changes:
- Updated constructor parameter handling to use explicit undefined checks instead of default parameter syntax
- Modified TypeScript interface to make
maxQueueSizea required property - Added comprehensive test coverage for all three initialization scenarios
Reviewed changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| lib/RateLimiterQueue.js | Refactored constructor to properly handle default values when empty options object is passed |
| types.d.ts | Changed maxQueueSize from optional to required property in IRateLimiterQueueOpts interface |
| test/RateLimiterQueue.test.js | Added three new test cases covering no opts, explicit opts, and empty opts scenarios |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
animir
reviewed
Dec 6, 2025
animir
reviewed
Dec 6, 2025
Owner
|
@sevauni Hey, this PR looks almost ready. I put a couple of comments. |
a5906b3 to
ac398a2
Compare
… key property from the opts
animir
approved these changes
Dec 13, 2025
Owner
|
Thank you for PR updates. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue: RateLimiterQueue maxQueueSize defaults to undefined when opts is passed without it
When creating a
RateLimiterQueuewith an options object like this{}then defaulting in the constructor doesn't work correctly but d.ts types allowed it thus leading to the runtime errors like this oneit happens because 0 < undefined evaluates to false
How to reproduce
After Fix
new RateLimiterQueue(limiter)-> uses default MAX_QUEUE_SIZEnew RateLimiterQueue(limiter, { maxQueueSize: 100 })-> uses 100new RateLimiterQueue(limiter, {})-> No TypeScript Errors uses default MAX_QUEUE_SIZE