Improved API response handling to prevent data loss - #1105
Open
girishpanchal30 wants to merge 3 commits into
Open
Improved API response handling to prevent data loss#1105girishpanchal30 wants to merge 3 commits into
girishpanchal30 wants to merge 3 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Prevents account data loss by awaiting persistence before reloading the dashboard.
Changes:
- Centralizes popup account persistence.
- Propagates AJAX failures to callers.
- Adds explicit success flags to account API responses.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
vue/src/vue-elements/sign-in-btn.vue |
Awaits account storage before reload. |
vue/src/models/rop_store.js |
Rejects failed AJAX promises. |
includes/admin/class-rop-rest-api.php |
Returns account persistence status. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.
Suppressed comments (2)
vue/src/vue-elements/sign-in-btn.vue:930
- This catch also handles transport failures from
fetchAJAXPromise, butservice_errorsays the service "can not be used or was not found." For an offline/timeout failure that diagnosis is incorrect and gives the user no useful recovery action. Please use a dedicated localized persistence/connection error such as “Could not save the %s account. Check your connection and try again.”
message: wp.i18n.sprintf( this.labels.service_error, this.displayName( serviceName ) )
vue/src/vue-elements/sign-in-btn.vue:895
- The ordering that fixes #1099 is currently untested, so a later move of the reload can silently restore the data-loss race. The existing accounts E2E spec only checks button visibility. This can be tested deterministically without a negative timeout: route/fulfill an auth-app URL in Playwright (which preserves that external origin), delay the add-account REST response, post the popup message, and assert the REST response completes before the parent navigation. Please add regression coverage for this shared popup flow.
// The account has to be stored before the dashboard reloads: reloading while the
// request is in flight lets the browser cancel it and the account is lost.
try {
await storing;
selul
requested changes
Aug 4, 2026
selul
left a comment
Contributor
There was a problem hiding this comment.
Two of the new rejection handlers throw instead of consuming the rejection.
selul
approved these changes
Aug 4, 2026
Soare-Robert-Daniel
approved these changes
Aug 4, 2026
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.
Summary
Improved the error handling for social account connections and updated the
fetchAJAXPromiseaction to properly handle promise rejections by logging errors and allowing upstream callers to handle errors gracefully.Check before Pull Request is ready:
Closes #1099
Why no test
The authorization popup is served by
app.revive.social, andgetChildWindowMessageonly accepts messages from that origin. Covering this in a test would require stubbing the external authentication app as a separate origin in the test harness. The existing E2E mock only intercepts server-side HTTP requests viapre_http_requestand cannot interact with a cross-origin browser popup.Additionally, the regression we're guarding against is a "reload fired too early" scenario, which would require asserting that a page navigation does not occur within a given time window. That type of negative timing assertion tends to be inherently flaky, making it a poor fit for a reliable automated test.