Skip to content

fix: resolve race condition and state accumulator in file browser#265

Open
HUmnanANirudh wants to merge 2 commits into
dbpedia:masterfrom
HUmnanANirudh:fix/file-browser
Open

fix: resolve race condition and state accumulator in file browser#265
HUmnanANirudh wants to merge 2 commits into
dbpedia:masterfrom
HUmnanANirudh:fix/file-browser

Conversation

@HUmnanANirudh

@HUmnanANirudh HUmnanANirudh commented Jun 28, 2026

Copy link
Copy Markdown

Summary

This PR fixes issue #262 where switching between versions or content variants could cause the File Browser to display incorrect total size and file count values.

Root Cause

Multiple SPARQL requests can finish out of order, allowing older responses to overwrite newer ones and display incorrect file counts and total size. This change also computes the totals using local variables before updating the UI state.

Changes

  • Introduce request revision with lastRequestRevision to ignore stale SPARQL responses.
  • Calculate totalSize, numFiles, and uriList using local variables before updating the controller state.
  • Update the UI only with the results of the most recent completed request.

Summary by CodeRabbit

  • Bug Fixes
    • Improved file browser search results to avoid outdated responses replacing newer ones.
    • Made result loading more reliable, with cleaner handling of loading state and errors.
    • Search results now better preserve file details, counts, and total size information.

@coderabbitai

coderabbitai Bot commented Jun 28, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@HUmnanANirudh, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 53 minutes and 18 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 48ae4db7-9845-454c-af37-abab95706df1

📥 Commits

Reviewing files that changed from the base of the PR and between d97599e and 30cac3a.

📒 Files selected for processing (1)
  • public/js/components/file-browser/file-browser.js
📝 Walkthrough

Walkthrough

querySparql in file-browser.js is refactored to add a request-revision guard preventing stale concurrent responses from overwriting state, replace for..in with for..of over updateResponse.data.results.bindings, parse sizes with an explicit radix, and change console.log to console.error in the catch block.

file-browser.js querySparql refactor

Layer / File(s) Summary
querySparql rewrite
public/js/components/file-browser/file-browser.js
Adds lastRequestRevision increment and early-return guard for out-of-order responses; extracts bindings via updateResponse.data.results.bindings; replaces for..in with for..of; parses binding.size.value with radix 10; conditionally formats binding.variant; assigns queryResult.bindings, queryResult.uriList, totalSize, numFiles; switches catch to console.error.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main fix: preventing stale file-browser requests from corrupting accumulated state.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@public/js/components/file-browser/file-browser.js`:
- Around line 156-158: The catch block in file-browser request handling clears
loading state without checking whether the failure belongs to the active
request, which can let an older SPARQL request override a newer one. Update the
error path in the relevant request flow (the same place that uses the request
revision for success handling) to compare the current request revision before
calling ctrl.isLoading = false or otherwise mutating UI state, and ignore stale
failures the same way the success path does.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 40a01e47-d674-4daf-a24d-0f78f8c65576

📥 Commits

Reviewing files that changed from the base of the PR and between 2c775e7 and d97599e.

📒 Files selected for processing (1)
  • public/js/components/file-browser/file-browser.js

Comment thread public/js/components/file-browser/file-browser.js Outdated
@HUmnanANirudh

Copy link
Copy Markdown
Author

@m1ci @holycrab13 Could you please review this when you have a chance?
Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant