Sync - something off with request usage

Hey team, I'm noticing something weird with Sync request usage. Everyday I have few hours of syncs because I'm syncing shopifyCustomer on install. But on September 26th I had no installs but still almost 9hrs request usage for Syncs. So I've digged a bit into nightly reconciliation but it looks like you guys made some changes that triggers nightly reconciliation for sync-only models only. So right now, only the shopifyAppUsageRecord is syncing every night. And this model is very fast to sync for each shop (few ms). So I really can't understand where the 9hrs of request usage are coming from. Also another issue: it looks like each shop is running nightly reconciliation 5 times (see screenshot) Can someone take a look at what's happening here please? App: monster-store-credit.gadget.app
No description
No description
23 Replies
Smelvin
Smelvin5d ago
Hi Yaman, we will investigate
Yaman
YamanOP4d ago
I've checked few days this month: even with barely no customers synced I have at least 6-7 hrs of used request usage for Sync. That's concerning to me guys because my Sync usage is 1/3 of my global usage...
No description
[Gadget] Kyle
[Gadget] Kyle4d ago
Hi Yaman, I'm currently working on making this more clear in our reports and in our docs, because this is confusing So first off let me distinguish between API triggered syncs and Webhook reconciliation syncs API triggered syncs -- these are the syncs that are triggered by calling shopifySync.run or from the scheduledShopifySync global action. These syncs write a record to the shopifySync table (the ones you show above), can be aborted etc. etc. Webhook reconciliation syncs - these are syncs that initiated nightly on all models that have webhook triggers who's main purpose is to make sure that all data from webhooks in the day was correctly delivered; we do not write a record into the shopifySync table for these and in fact in Gadget 1.5 we are not even going to call this a sync; the trigger object is going to become shopify_webhook_reconciliation ; we are also going to chang the trigger type from shopifyCustomer - Sync to shopifyCustomer - Webhook reconciliation in the billing reports (that should roll out today or tomorrow) Now as to why shopifyCustomer - Webhook reconciliation is causing a lot of request time: Shopify unfortunately does not standardize the data that they send in webhook payloads with what is available in the graphql API; as a result there are fields on models like shopifyCustomer that we call "sync only fields", these fields will be NULL when created via a webhook trigger; however they often contain very useful data, so when the nightly reconciliation sync for shopify customer runs, if there is a record that has data in one of these fields we will run the update action with the missing data as a result, if you stores that are often updating these sync only fields, then your action will end up running twice: once when the customer/update webhook arrives and again later that night when the reconciliation sync runs and discovers that one of these "sync only fields" is changed In a future version of Gadget (1.6 which should be released mid to late October) we are going to give users full control and visibility into which fields on which models cause this behaviour; but in the meantime these are the fields on shopify customer that could be causing this request time usage for you:
acceptsMarketing
acceptsMarketingUpdatedAt
lastOrderName
marketingOptInLevel
numberOfOrders
tags
emailMarketingConsent
smsMarketingConsent
statistics
locale
amountSpent
canDelete
legacyResourceId
lifetimeDuration
productSubscriberStatus
unsubscribeUrl
validEmailAddress
hasTimelineComment
dataSaleOptOut
acceptsMarketing
acceptsMarketingUpdatedAt
lastOrderName
marketingOptInLevel
numberOfOrders
tags
emailMarketingConsent
smsMarketingConsent
statistics
locale
amountSpent
canDelete
legacyResourceId
lifetimeDuration
productSubscriberStatus
unsubscribeUrl
validEmailAddress
hasTimelineComment
dataSaleOptOut
If you do not care about any of these fields you can remove them from your shopifyCustomer model and the webhook reconciliation will no longer need to run actions when it looks at the state of the data in Shopify vs the state of the data in your Gadget app this is a really annoying gotcha about the shopify webhook/graphql discrepency that we are working hard to surface in the upcoming version of Gadget -- any comments or feedback is greatly appreciated
Yaman
YamanOP4d ago
This doc is outdated? https://docs.gadget.dev/guides/plugins/shopify/syncing-shopify-data#sync-only-fields I already removed sync-only field based on this doc, this is why I was not even looking at a sync-only field issue... 😕
No description
Yaman
YamanOP4d ago
also having includeFields filter doesn't apply on the nightly reconciliation?
No description
Yaman
YamanOP4d ago
includeFields should also apply for nightly webhook reconciliation if I understand this statement correctly
No description
[Gadget] Kyle
[Gadget] Kyle4d ago
yes although maybe there is a bug in that let me dig in further ah you have last_order_name in the included fields which is a sync only field I think and yes that list in the docs is out of date; we are going to power it from source of truth metadata; just working on a fix for that now
Yaman
YamanOP4d ago
No description
Yaman
YamanOP4d ago
the whole list I've put in my includeFields comes from a real webhook payload I've took example on back then
[Gadget] Kyle
[Gadget] Kyle4d ago
thanks; I think our metadata is mistaken then; going to dig in more
includeFields should also apply for nightly webhook reconciliation if I understand this statement correctly
ok there is a bug with this; fixing now
Yaman
YamanOP4d ago
Thanks Kyle. Can you know for how long it has been bugged and how much request usage I used because of it? Right now, Sync is about 30% of my total so that’s quite a big impact for me
[Gadget] Kyle
[Gadget] Kyle4d ago
oh wait @Yaman that's the rest API you referenced here is the schema of the customers/update webhook https://shopify.dev/docs/api/webhooks?accordionItem=webhooks-customers-update&reference=toml some of your include fields are sync only fields
MEE6
MEE64d ago
yaman.dev has been warned
Reason: Bad word usage
Yaman
YamanOP4d ago
Ooups sorry, I was saying f***, they removed it on version 2025-01 ☠️ https://shopify.dev/changelog/new-customer-s-webhook-and-changes-to-existing-customer-s-webhooks-payload
[Gadget] Kyle
[Gadget] Kyle4d ago
oh damn that's annoying what we are working on for sync only fields will help you a lot here
Yaman
YamanOP4d ago
yeah, looks like a big edge case with a big impact... not sure how to prevent that tho.. do you plan to support customers/purchasing_summary in the near future?
[Gadget] Kyle
[Gadget] Kyle4d ago
soon you will be able to have the ability to know exactly which fields on your api version are sync only and you will have the option to sync the data at webhook receive time or to wait for the reconciliation sync
do you plan to support customers/purchasing_summary in the near future?
we won't have it trigger the customer update action; but I think you could do 1 of 2 things today 1. in the on success of shopifyCustomer#update fetch the data you care about from the graphql api (be wary of rate limit consumption) 2. create a global action that is triggered by customers/purchasing_summary and update the corresponding record in your db I think 2 is my recommendation
Yaman
YamanOP4d ago
OK thanks but just to confirm, even if I go with solution 2, I will still have high Sync usage if I keep the sync only field in the model right?
[Gadget] Kyle
[Gadget] Kyle4d ago
yes but I think you could remove those sync only fields from includedFields in your trugger then you won't
Yaman
YamanOP4d ago
gotcha, yeah seems to be the way to go right now thanks for digging, hard one to catch ☠️
[Gadget] Kyle
[Gadget] Kyle4d ago
no problem; this stuff if complicated (my mind is constantly in a shopify api pretzel) and the more we can smooth this over for users the better!
Yaman
YamanOP13h ago
hey Kyle, since the doc is outdated, would you mind giving the sync-only fields for - shopifyOrder - shopifyOrderTransaction thanks Hey @[Gadget] Kyle sorry for the ping but you might have missed this message
muchi
muchi11h ago
Hey Yaman, the docs have been updated with the updated list of sync only fields for models. This will be deployed to production shortly!

Did you find this page helpful?