-
Notifications
You must be signed in to change notification settings - Fork 46
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
fix: change historical to false for events #329
fix: change historical to false for events #329
Conversation
WalkthroughThe pull request modifies the Changes
Possibly related PRs
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (1)
packages/state/src/recs/index.ts (1)
Based on the search results and documentation comments, I can now generate the final response.
Confirmed: The original review comment correctly identified a critical issue
The change from
length < limit
tolength === 0
is problematic because:
- The documentation explicitly states that the function "fetches entities in batches, controlled by the 'limit' parameter"
- The original logic using
length < limit
is the correct implementation for batch-based pagination, as it properly detects when we've received fewer items than requested- The new condition
length === 0
breaks the batch processing contract and can lead to infinite loops when the total number of entities is exactly divisible by the limitThe original review's recommendation to either:
- Revert to
length < limit
(Option 1)- Use both conditions
length === 0 || length < limit
(Option 2)is correct and should be followed to maintain proper pagination behavior.
🔗 Analysis chain
Line range hint
190-194
: Critical: Potential infinite loop in pagination logicThe new condition
Object.keys(entities).length === 0
could lead to an infinite loop if:
- The total number of entities is exactly divisible by the limit
- The server consistently returns
limit
number of entities but has no more dataConsider one of these safer approaches:
- if (Object.keys(entities).length === 0) { + // Option 1: Keep original logic (safer) + if (Object.keys(entities).length < limit) { + continueFetching = false; + } else { + offset += limit; + } + // Option 2: Add both conditions + if (Object.keys(entities).length === 0 || Object.keys(entities).length < limit) { continueFetching = false; } else { offset += limit; }
Let me gather more context about the pagination logic by examining the implementation.
The search results show both the old and new implementations of the pagination logic in the same file. Let me examine the full context of this function to understand its purpose and interaction with the server.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Search for similar pagination patterns in the codebase echo "Searching for pagination patterns..." rg "continueFetching.*length.*limit" --type ts -A 5 -B 5Length of output: 1853
Script:
#!/bin/bash # Search for the getEvents function implementation ast-grep --pattern 'export async function getEvents($_) { $$$ }' # Also search for any similar pagination patterns rg "offset.*limit" --type ts -A 5 -B 5Length of output: 1262
Script:
#!/bin/bash # Get the full context of the file around getEvents function rg -B 20 -A 20 "async function getEvents" packages/state/src/recs/index.ts # Also check if there are any comments or documentation about pagination rg "pagination|fetch.*limit" --type ts packages/state/src/recs/index.tsLength of output: 371
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (1)
packages/state/src/recs/index.ts
(5 hunks)
🔇 Additional comments (2)
packages/state/src/recs/index.ts (2)
66-66
: LGTM: Documentation updates are accurate and consistent
The JSDoc updates correctly reflect the new default value of historical: false
across all affected functions.
Also applies to: 161-161, 304-304
169-169
: Verify impact of breaking change
Changing the default value of historical
from true
to false
is a breaking change that could affect existing consumers who rely on the default behavior. Consider:
- Adding a migration guide
- Verifying all call sites
#!/bin/bash
# Search for direct calls to affected functions to assess impact
echo "Searching for getEvents calls..."
rg "getEvents\(" --type ts
echo "Searching for syncEvents calls..."
rg "syncEvents\(" --type ts
# Search for indirect calls through getSyncEvents
echo "Searching for getSyncEvents calls..."
rg "getSyncEvents\(" --type ts
Also applies to: 316-316
Summary by CodeRabbit
These changes streamline event synchronization and retrieval processes for a smoother user experience.