Repository navigation
fix: prevent duplicate syncs from the Review Content Updates tab - #3316
syedsajjadkazmii wants to merge 2 commits into
Conversation
The "Update" button on a review card stopped its spinner as soon as the sync POST returned, but the card only went away after the ready-to-sync links and then the search results were refetched. In that gap the old card showed an active "Update" button, and clicking it sent the same sync again. - Wait for the links refetch before resolving the Update click, so the button stays pending until the list is current. - Drop search hits that are no longer in the ready-to-sync links, so a synced card is not shown while the search results catch up. - Add outOfSyncItemsByKey to the updateBlock dependencies. It was captured from the first render, so an item that became ready to sync later failed after a successful sync and its card was not refreshed.
|
Thanks for the pull request, @syedsajjadkazmii! This repository is currently maintained by Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are ready for engineering review. 🔘 Get product approvalIf you haven't already, check this list to see if your contribution needs to go through the product review process.
🔘 Provide contextTo help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:
🔘 Get a green buildIf one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green. DetailsWhere can I find more information?If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources: When can I expect my changes to be merged?Our goal is to get community contributions seen and reviewed as efficiently as possible. However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:
💡 As a result it may take up to several weeks or months to complete a review and merge your PR. |
Read the link data before the sync so a later lookup cannot fail after a successful sync, and fix the invalidateLinksQuery docstring typo.
Backport of openedx#3316 to release/ulmo.2 for EDL. The "Update" button on a review card stopped its spinner as soon as the sync POST returned, but the card only went away after the ready-to-sync links and then the search results were refetched. In that gap the old card showed an active "Update" button, and clicking it sent the same sync again. - Wait for the links refetch before resolving the Update click, so the button stays pending until the list is current. - Drop search hits that are no longer in the ready-to-sync links, so a synced card is not shown while the search results catch up. - Add outOfSyncItemsByKey to the updateBlock dependencies. It was captured from the first render, so an item that became ready to sync later failed after a successful sync and its card was not refreshed.
Description
Fixes duplicate sync requests from the course Libraries > Review Content Updates tab. Users had to click "Update" an unpredictable number of times, and each extra click sent another
POST /api/contentstore/v2/downstreams/<usage_key>/sync.Impacted role: Course Author.
Cause
Clicking "Update" puts the
LoadingButtonin its pending state untilupdateBlockresolves.updateBlockresolved as soon as the sync POST returned. The card, however, is only removed after two more requests:invalidateLinksQuerywas not awaited), thenusage_key IN [...]filter.Until both finished, the old card showed an active "Update" button. Measured on a production instance with a single click: sync POST 0.8 s, spinner cleared at 10.25 s, links refetched at 10.53 s, card removed at 10.75 s. The server logs show the same block synced twice, 5 s apart. The gap grows with network and server latency, which is why the bug is intermittent.
Changes
updateBlockawaits the links refetch, so the button stays pending until the list is current. If the item is still ready to sync after the refetch, the button becomes active again (no stuck spinner).updateBlockhad an emptyuseCallbackdependency list, so it usedoutOfSyncItemsByKeyfrom the first render. For an item that became ready to sync after the page loaded, the lookup threw after a successful sync: the user saw "Failed to update component" and the card was not refreshed. It now depends onoutOfSyncItemsByKey.invalidateLinksQueryreturns theinvalidateQueriespromise so it can be awaited. It is added to theno-floating-promisesknown-safe calls next toinvalidateQueries, so existing fire-and-forget callers are unchanged.Supporting information
Reported by course authors on an Open edX production instance (Teak-based Studio).
Testing instructions
Automated tests added in
CourseLibraries.test.tsx:The first and third fail on
master.Other information
No backend changes. The ignore flow and the preview modal still refresh the links without waiting; they close a modal and are not affected by this bug.
Best Practices Checklist
.ts,.tsx).propTypesanddefaultPropsin any new or modified code.src/testUtils.tsx(specificallyinitializeMocks)apiHooks.tsin this repo for examples.messages.tsfiles have adescriptionfor translators to use.../in import paths. To import from parent folders, use@src, e.g.import { initializeMocks } from '@src/testUtils';instead offrom '../../../../testUtils'🤖 Generated with Claude Code