woocommerce / woocommerce-square

Square POS and Payments Integration
https://woo.com/products/square
Other
11 stars 7 forks source link

Sync process is not updating or importing new products in WordPress from square. #193

Closed sunile2m closed 3 months ago

sunile2m commented 3 months ago

Describe the bug

I have around 800 products in the Square. I clicked "Import all Products from Square" and it started syncing products from Square(Production) to WordPress. It was syncing products for the next 10-15 minutes and after that, the process is not updating any number or products. It seems like it is in an infinite loop. The sync only stops if I manually clear jobs and delete them.

Screenshots

Please take a look at the attached screenshot in sequence and note the time if it help you to understand the issue. 1) Sync Started: Sync Screen: https://capture.dropbox.com/kSzqFv6mWV6FTjeh In Progress: Actions: https://capture.dropbox.com/tjO2Xu4ziKHVEquM Pending Actions: https://capture.dropbox.com/iyYh9bH3GofjtQ4n

2) After 5 mins: it shows that some (100) existing products have been updated. Sync Screen: https://capture.dropbox.com/7fHx6b150b86sNRC

3) After 10 mins, it shows that some (200) existing products have been updated. Sync Screen: https://capture.dropbox.com/brlVZXF3SMjiwjo0

4) After 1 hour: no more products are updated or new products are imported. Sync Screen: https://capture.dropbox.com/w5ZTv4QHv1qYktbR In Progress: Actions: https://capture.dropbox.com/Is4obcrfkhB6rCpL Pending Actions: https://capture.dropbox.com/G63BIInZVmLAxEfc

Expected behavior

It should sync all the products from square. As nothing is changed and it was working as expected before 15 days.

Environment (please complete the following information):

Additional details

I checked the debug.log file every time. There is no error in that file.

System status ``` ` ### WordPress Environment ### WordPress address (URL): ---removed--- Site address (URL): ---removed--- WC Version: 9.1.4 Legacy REST API Package Version: The Legacy REST API plugin is not installed on this site. Action Scheduler Version: ✔ 3.7.4 Log Directory Writable: ✔ WP Version: ❌ 6.5.5 - There is a newer version of WordPress available (6.6.1) WP Multisite: – WP Memory Limit: 256 MB WP Debug Mode: ✔ WP Cron: ✔ Language: en_US External object cache: – ### Server Environment ### Server Info: Apache PHP Version: 8.0.30.2 PHP Post Max Size: 100 MB PHP Time Limit: 300 PHP Max Input Vars: 10000 cURL Version: 8.5.0 OpenSSL/3.1.6 SUHOSIN Installed: – MySQL Version: 8.0.33-25 Max Upload Size: 100 MB Default Timezone is UTC: ✔ fsockopen/cURL: ✔ SoapClient: ✔ DOMDocument: ✔ GZip: ✔ Multibyte String: ✔ Remote Post: ✔ Remote Get: ✔ ### Database ### WC Database Version: 9.1.4 WC Database Prefix: wp_************_ Total Database Size: 168.47MB Database Data Size: 114.27MB Database Index Size: 54.20MB ### Post Type Counts ### acf-field: 4 acf-field-group: 2 acf-ui-options-page: 1 attachment: 1554 br_filters_group: 1 br_product_filter: 10 custom_css: 1 elementor_font: 1 elementor_icons: 1 elementor_library: 69 elementor_snippet: 1 inavii_account: 1 inavii_feed: 1 inavii_ig_media: 50 nav_menu_item: 43 page: 22 post: 2 product: 251 product_variation: 1183 revision: 444 shop_order: 24 shop_order_placehold: 22 shop_order_refund: 1 wp_font_face: 33 wp_font_family: 12 wp_global_styles: 1 ### Security ### Secure connection (HTTPS): ✔ Hide errors from visitors: ✔ ### Active Plugins (22) ### Inavii for Elementor Social Feed: by INAVII – 2.6.9 Advanced Custom Fields PRO: by WP Engine – 6.3.4 FiboSearch - AJAX Search for WooCommerce: by FiboSearch Team – 1.28.1 All-in-One WP Migration Unlimited Extension: by ServMask – 2.59 All-in-One WP Migration: by ServMask – 7.84 Disable Emails: by WebAware – 1.8.2 Elementor Pro: by Elementor.com – 3.23.2 Elementor: by Elementor.com – 3.23.3 Email Log: by Sudar – 2.4.9 Envato Elements: by Envato – 2.0.13 Feeds for YouTube: by Smash Balloon YouTube Team – 2.2.2 USPS Live Rates: by Octolize – 1.10.3 PW WooCommerce Gift Cards: by Pimwick LLC – 2.0 VamTam Elementor Integration (Debebe): by VamTam – 1.0.14 VamTam Importers (E): by VamTam – 1.2.4 Extra product options For WooCommerce | Custom Product Addons and Fields: by ThemeHigh – 3.2.7 WPC Smart Wishlist for WooCommerce: by WPClever – 4.8.9 WooCommerce.com Update Manager: by Automattic – 1.0.3 Advanced AJAX Product Filters for WooCommerce: by BeRocket – 1.6.4.6 WooCommerce Square: by WooCommerce – 4.7.2 WooCommerce: by Automattic – 9.1.4 WP Crontrol: by John Blackbourn – 1.17.0 ### Inactive Plugins (17) ### 404 to 301 - Redirect, Log and Notify 404 Errors: by Joel James – 3.1.4 Akismet Anti-spam: Spam Protection: by Automattic - Anti-spam Team – 5.3.3 CoBlocks: by GoDaddy – 3.1.13 Custom Twitter Feeds: by Smash Balloon – 2.2.2 Download Plugin: by Metagauss – 2.1.0 Feeds for TikTok (TikTok feed, video, and gallery plugin): by Smash Balloon – 1.0.2 Formidable Forms: by Strategy11 Form Builder Team – 6.11.2 Formidable Forms Pro: by Strategy11 – 6.5.3 Product Questions & Answers for WooCommerce: by VamTam – 1.1.2 Reviews Feed: by Smash Balloon – 1.2.0 Site Kit by Google: by Google – 1.132.0 Smash Balloon Custom Facebook Feed: by Smash Balloon – 4.2.5 Smash Balloon Instagram Feed: by Smash Balloon – 6.5.0 WooCommerce Shipping & Tax: by WooCommerce – 2.7.0 WooCommerce USPS Shipping: by WooCommerce – 5.0.0 WP-Optimize - Clean, Compress, Cache: by David Anderson Ruhani Rabin Team Updraft – 3.4.2 Yoast SEO: by Team Yoast – 23.1 ### Dropin Plugins () ### db-error.php: db-error.php object-cache.php: object-cache.php ### Must Use Plugins (2) ### Object Cache Pro (MU): by Rhubarb Group – 1.21.2 System Plugin: by – 4.134.0 ### Settings ### API Enabled: – Force SSL: – Currency: USD ($) Currency Position: left Thousand Separator: , Decimal Separator: . Number of Decimals: 2 Taxonomies: Product Types: external (external) grouped (grouped) pw gift card (pw-gift-card) simple (simple) subscription (subscription) variable (variable) variable subscription (variable-subscription) variation (variation) Taxonomies: Product Visibility: exclude-from-catalog (exclude-from-catalog) exclude-from-search (exclude-from-search) featured (featured) outofstock (outofstock) rated-1 (rated-1) rated-2 (rated-2) rated-3 (rated-3) rated-4 (rated-4) rated-5 (rated-5) Connected to WooCommerce.com: ✔ Enforce Approved Product Download Directories: ✔ HPOS feature enabled: ✔ Order datastore: Automattic\WooCommerce\Internal\DataStores\Orders\OrdersTableDataStore HPOS data sync enabled: – ### Logging ### Enabled: ✔ Handler: Automattic\WooCommerce\Internal\Admin\Logging\LogHandlerFileV2 Retention period: 7 days Level threshold: – Log directory size: 5 MB ### WC Pages ### Shop base: #6 - /shop/ Cart: ❌ Page does not contain the [woocommerce_cart] shortcode or the woocommerce/cart block. Checkout: #8 - /checkout/ - Contains the [woocommerce_checkout] shortcode My account: #9 - /my-account/ Terms and conditions: #1672 - /terms-conditions/ ### Theme ### Name: DeBebe Child Version: (update to version 0 is available) Author URL: https://vamtam.com Child Theme: ✔ Parent Theme Name: (VamTam) DeBebe Parent Theme Version: 4.1 Parent Theme Author URL: https://vamtam.com WooCommerce Support: ✔ ### Templates ### Overrides: vamtam-debebe/woocommerce/cart/cart-shipping.php vamtam-debebe/woocommerce/cart/cart.php debebe-child/woocommerce/checkout/review-order.php vamtam-debebe/woocommerce/global/wrapper-end.php vamtam-debebe/woocommerce/global/wrapper-start.php vamtam-debebe/woocommerce/loop/loop-start.php vamtam-debebe/woocommerce/loop/orderby.php debebe-child/woocommerce/myaccount/form-login.php vamtam-debebe/woocommerce/single-product/rating.php ### Square ### Environment: Production Tokenization Enabled: – Debug Mode: Off ### Admin ### Enabled Features: activity-panels analytics product-block-editor coupons core-profiler customize-store customer-effort-score-tracks import-products-task experimental-fashion-sample-products shipping-smart-defaults shipping-setting-tour homescreen marketing mobile-app-banner navigation onboarding onboarding-tasks product-custom-fields remote-inbox-notifications remote-free-extensions payment-gateway-suggestions shipping-label-banner subscriptions store-alerts transient-notices woo-mobile-welcome wc-pay-promotion wc-pay-welcome-page launch-your-store Disabled Features: experimental-blocks minified-js pattern-toolkit-full-composability product-pre-publish-modal printful settings async-product-editor-category-field product-editor-template-system Daily Cron: ✔ Next scheduled: 2024-07-28 07:26:06 -05:00 Options: ✔ Notes: 9 Onboarding: - ### Action Scheduler ### Complete: 70,103 Oldest: 2024-06-29 15:33:39 +0000 Newest: 2024-07-29 13:42:16 +0000 In-progress: 1 Oldest: – Newest: – Pending: 93 Oldest: 2024-07-31 09:46:02 +0000 Newest: 2024-08-05 13:42:16 +0000 ### Status report information ### Generated at: 2024-07-31 06:18:30 -05:00 ` ```
sunile2m commented 3 months ago

I see a WooComm log file.

I see hundreds of entries for uri: listLocations within the same action execution. Seems like it is in an infinite loop of getting store locations. I see 100+ times below log for single action execution

2024-07-31T11:10:57+00:00 NOTICE Request
 Request
method:
uri: listLocations
user-agent: WooCommerce-Square/4.7.2 (WooCommerce/9.1.4; WordPress/6.5.5)
headers: Array
(
)
body:
duration: 0.14488s
 CONTEXT: {"_legacy":true}
iamdharmesh commented 3 months ago

Hi @sunile2m,

Thank you for reporting the issue and providing all the information.

I have started checking this and trying to reproduce the issue, but so far I have not been able to. I am now testing with improper data, such as a product without an SKU. In the meantime, could you please help by checking for repetitive logs? You can enable and check the logs by following the steps below:

1. Enable debug logs:

image

2. Check for repetitive logs or any errors:

image

Thank you.

Note: We recently encountered a similar issue and fixed it, but it appears to be slightly different from this one.

sunile2m commented 3 months ago

HI @iamdharmesh,

Thank you for responding.

I have requested the client to share the Square debug log file. Just for your information, I was able to resolve the issue by adding the below filters to my child theme. I am not sure if this is the correct fix for the time being or not, In WC Scheduled Actions, I did see "wc_square_job_runner" always failed due to time out. So tried adding the below lines.

function lp_change_wc_square_import_api_limit( $limit ) {
    return 25;
}
add_filter( 'wc_square_import_api_limit', 'lp_change_wc_square_import_api_limit' );

function lp_increase_action_scheduler_concurrent_batches( $concurrent_batches ) {
    return 2;
}
add_filter( 'action_scheduler_queue_runner_concurrent_batches', 'lp_increase_action_scheduler_concurrent_batches' );

function lp_increase_scheduler_queue_runner_time_limit( $time_limit ) {
    return 120;
}
add_filter( 'action_scheduler_queue_runner_time_limit', 'lp_increase_scheduler_queue_runner_time_limit' );
iamdharmesh commented 3 months ago

Thanks for the details, @sunile2m. I’m glad to hear that the issue has been resolved by this limit tweak.

I tried to reproduce the issue on my side but was unable to do so. However, I did notice that if we have a product without SKU, the sync can get stuck during manual synchronization. This issue has already been fixed in PR #185.

@vikrampm1, since we are unable to reproduce this issue and it has already been resolved for the original reporter by adjusting the limits, I think we are good to close this. We can reopen it if we receive similar reports in the future.

Thanks!