Fix page dedup cache preventing retry after failed API calls#94
Fix page dedup cache preventing retry after failed API calls#94JeroenDeDauw wants to merge 1 commit intomasterfrom
Conversation
📝 WalkthroughWalkthroughThe Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Tip Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs). 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. Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
resources/js/ApiPageConnectionRepo.js (1)
21-33:⚠️ Potential issue | 🟠 MajorHandle API failure paths so
addConnectionsalways settles.If
_queryLinksfails, this Promise never resolves/rejects because only.doneis wired. That can stall callers and retry flows.Suggested fix
ApiPageConnectionRepo.prototype.addConnections = function(pageNames) { return new Promise( - function(resolve) { + function(resolve, reject) { let pagesToAdd = pageNames.filter(page => !this._addedPages.includes(page)); if (pagesToAdd.length === 0) { resolve({pages: [], links: []}); } else { this._queryLinks(pagesToAdd).done( function(apiResponse) { - this._addedPages = this._addedPages.concat(pagesToAdd); - this._apiResponseToPagesAndLinks(apiResponse).then(connections => resolve(connections)) + this._apiResponseToPagesAndLinks(apiResponse) + .then(connections => { + this._addedPages = this._addedPages.concat(pagesToAdd); + resolve(connections); + }) + .catch(reject); }.bind(this) - ); + ).fail(reject); } }.bind(this) ); };🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@resources/js/ApiPageConnectionRepo.js` around lines 21 - 33, The Promise returned in addConnections (the new Promise executor using pageNames and this._queryLinks) never settles when this._queryLinks fails because only .done is used; update the call to handle error paths (e.g., use .then/.catch or attach .fail/.always) so that failures either reject the outer Promise or resolve it with a safe value, and ensure the same this binding is preserved for the success and error handlers on this._queryLinks; specifically, modify the block around this._queryLinks(pagesToAdd).done(...) to add an error handler that calls reject(...) or resolve({pages:[],links:[]}) as appropriate and keep using .bind(this) (or arrow functions) so this._addedPages and this._apiResponseToPagesAndLinks are available.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In `@resources/js/ApiPageConnectionRepo.js`:
- Around line 21-33: The Promise returned in addConnections (the new Promise
executor using pageNames and this._queryLinks) never settles when
this._queryLinks fails because only .done is used; update the call to handle
error paths (e.g., use .then/.catch or attach .fail/.always) so that failures
either reject the outer Promise or resolve it with a safe value, and ensure the
same this binding is preserved for the success and error handlers on
this._queryLinks; specifically, modify the block around
this._queryLinks(pagesToAdd).done(...) to add an error handler that calls
reject(...) or resolve({pages:[],links:[]}) as appropriate and keep using
.bind(this) (or arrow functions) so this._addedPages and
this._apiResponseToPagesAndLinks are available.
Summary by CodeRabbit