Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API Fetch: Prevent infinite retries when auth session is invalid #67452

Conversation

himanshupathak95
Copy link
Contributor

@himanshupathak95 himanshupathak95 commented Dec 2, 2024

What?

Prevent infinite API request loop when the user's authentication session becomes invalid during block editor usage.

Why?

Currently, when a user's authentication cookie (wordpress_logged_in) is removed while using the block editor, the API-fetch utility enters an infinite loop trying to refresh the nonce token. This causes:

  • Continuous failed API requests
  • High CPU usage
  • Potential browser unresponsiveness
  • Poor user experience

Testing Instructions

  1. Open the block editor for any post/page
  2. Open browser dev tools
  3. Go to the Application tab
  4. Find and delete the wordpress_logged_in cookie
  5. Make any changes and save draft
  6. Observe in Network tab:
  • Before fix: Continuous failing API requests
  • After fix: Single failed request, no retries

When user's authentication session becomes invalid (wordpress_logged_in
cookie is missing) while using the block editor, api-fetch currently
enters an infinite retry loop trying to refresh the nonce. This
fix checks for the auth cookie before attempting nonce refresh,
preventing unnecessary API requests.
@himanshupathak95
Copy link
Contributor Author

Closing in favor of #32475

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