Skip to content

Improved API response handling to prevent data loss - #1105

Open
girishpanchal30 wants to merge 3 commits into
developmentfrom
bugfix/1099
Open

Improved API response handling to prevent data loss#1105
girishpanchal30 wants to merge 3 commits into
developmentfrom
bugfix/1099

Conversation

@girishpanchal30

Copy link
Copy Markdown
Contributor

Summary

Improved the error handling for social account connections and updated the fetchAJAXPromise action 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, and getChildWindowMessage only 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 via pre_http_request and 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.

@girishpanchal30 girishpanchal30 added the pr-checklist-skip Allow this Pull Request to skip checklist. label Aug 3, 2026
@pirate-bot pirate-bot added the pr-checklist-complete The Pull Request checklist is complete. (automatic label) label Aug 3, 2026
@girishpanchal30
girishpanchal30 requested a review from Copilot August 3, 2026 11:19
@pirate-bot

pirate-bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Plugin build for c34c8e6 is ready 🛎️!

Copilot AI 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.

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.

Comment thread vue/src/models/rop_store.js
Comment thread vue/src/vue-elements/sign-in-btn.vue Outdated

Copilot AI 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.

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, but service_error says 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 selul left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Two of the new rejection handlers throw instead of consuming the rejection.

Comment thread vue/src/vue-elements/accounts-tab-panel.vue Outdated
Comment thread vue/src/vue-elements/post-format.vue Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-checklist-complete The Pull Request checklist is complete. (automatic label) pr-checklist-skip Allow this Pull Request to skip checklist.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants