[WIP] Fix intermittent file upload failures for users#575
[WIP] Fix intermittent file upload failures for users#575Claude wants to merge 7 commits intodevelopmentfrom
Conversation
There was a problem hiding this comment.
Copilot wasn't able to review any files in this pull request.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Added REST endpoint /ppom/v1/nonces/file/ to generate fresh nonces - Implemented ppom_refresh_file_nonces() JavaScript function with caching - Added BeforeUpload handler to refresh nonces before file uploads - Updated delete operation to refresh nonces before deletion - Exposed REST URL via wp_localize_script in frontend-scripts.class.php Agent-Logs-Url: https://github.com/Codeinwp/woocommerce-product-addon/sessions/fbc65e28-72b7-4dbf-a721-631e20fa5e98 Co-authored-by: poonam279 <27731529+poonam279@users.noreply.github.com>
- Added testGetFileNoncesReturnsSuccessWithNonces to verify endpoint structure - Added testGetFileNoncesGeneratesValidNonces to verify nonces are valid - Added testGetFileNoncesReturnsDifferentNoncesOnMultipleCalls for reliability - All 79 tests passing (76 existing + 3 new) Agent-Logs-Url: https://github.com/Codeinwp/woocommerce-product-addon/sessions/fbc65e28-72b7-4dbf-a721-631e20fa5e98 Co-authored-by: poonam279 <27731529+poonam279@users.noreply.github.com>
|
@claude[agent] can you merge with the new changes from development? Also, what are better way to go around stalled nonces on cached pages (list some alternatives)? |
Co-authored-by: Soare-Robert-Daniel <17597852+Soare-Robert-Daniel@users.noreply.github.com>
Merged with development in commit 4b40430. The nonce endpoint has been migrated to the new Alternative approaches to handling stale nonces on cached pages:
Why the current dynamic REST approach was chosen: ✅ Minimal code changes - works with existing nonce infrastructure All tests passing (193 tests, 509 assertions). Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
@claude[agent] can you also implement an E2E for file upload? Also, fix the PHPCS issues reported by the linter. |
- Fixed PHPCS inline comment punctuation in Routes.php - Removed unused $request parameter from get_file_nonces method - Added buildFileField helper to fixtures for E2E tests - Created comprehensive E2E test suite for file upload nonce refresh - Tests verify nonce refresh functionality, REST endpoint, and field rendering - All 193 PHPUnit tests passing Agent-Logs-Url: https://github.com/Codeinwp/woocommerce-product-addon/sessions/e2b99f26-9716-4f68-816a-ffcee4a47cde Co-authored-by: Soare-Robert-Daniel <17597852+Soare-Robert-Daniel@users.noreply.github.com>
Both tasks completed in commit d79b313: PHPCS Issues Fixed:
E2E Test Added:
Also added All 193 PHPUnit tests passing, PHPCS clean. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
@claude[agent] can you fix you E2E tests? Make sure to use the available wp-env to run the tests (it is already setup) E2E Errors···········××F××F··
2 failed Error: 1) [chromium] › tests/e2e/specs/file-upload.spec.js:73:6 › File Upload with Dynamic Nonce Refresh › should refresh nonce via REST endpoint Error: 1) [chromium] › tests/e2e/specs/file-upload.spec.js:73:6 › File Upload with Dynamic Nonce Refresh › should refresh nonce via REST endpoint Error: 2) [chromium] › tests/e2e/specs/file-upload.spec.js:140:6 › File Upload with Dynamic Nonce Refresh › should handle nonce refresh endpoint correctly Error: 2) [chromium] › tests/e2e/specs/file-upload.spec.js:140:6 › File Upload with Dynamic Nonce Refresh › should handle nonce refresh endpoint correctly Error: 2) [chromium] › tests/e2e/specs/file-upload.spec.js:140:6 › File Upload with Dynamic Nonce Refresh › should handle nonce refresh endpoint correctly Notice: 2 failed |
- Separated nonce refresh endpoint registration from API enable check - Added new init_nonce_api() method that always registers the nonce endpoint - Nonce endpoint doesn't require API to be enabled since nonces are public - Fixed E2E test timing issues - Added proper waitForFunction() calls to ensure JavaScript is loaded - Tests now wait for ppom_file_vars and ppom_refresh_file_nonces before assertions - All 3 E2E tests now passing 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> Co-authored-by: Soare-Robert-Daniel <17597852+Soare-Robert-Daniel@users.noreply.github.com>
... Fixed! The E2E tests were failing because the REST API nonce refresh endpoint wasn't registered (it required Changes in commit
Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
@claude[agent] can you fix the merge issues? Also, if we use the normal WP REST nonce, do you think it will be more compatible since popular plugins might have support for it? |
Soare-Robert-Daniel
left a comment
There was a problem hiding this comment.
We can iterate more on this regarding the nonce endpoint. We can see for alternatives.
- Combined nonce refresh REST URL with new file upload error messages - Resolved conflict in classes/frontend-scripts.class.php by including both changes Co-authored-by: Soare-Robert-Daniel <17597852+Soare-Robert-Daniel@users.noreply.github.com>
Merge conflicts fixed in commit About using While popular caching plugins like WP Rocket and LiteSpeed Cache have built-in exclusions for
The real issue was never about nonce compatibility with caching plugins—it was that static nonces in cached HTML become stale. Our REST endpoint ( If we switched to
But this wouldn't provide additional caching compatibility because the nonces are still embedded in JavaScript, not URL parameters where caching plugins look for them. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
Thanks for asking me to work on this. I will get started on it and keep this PR's description up to date as I form a plan and make progress.