Attributes set on cart sometimes don't get detected in the query Input

Hi,
I’m dealing with a stochastic and peculiar bug which I’m having trouble reproducing so I’ll open this thread to ask for feedback on how to troubleshoot it.

In a gist, the business case I’ve set up deals with incoming customers from a price comparison website (such as PriceRunner) and those customers need to receive a special discount according to the feed which was previously fed to the website. In order to that I’ve made it so that the cart gets updated with an attribute via a remix app and that attribute is then used to apply that discount.

Now, the issue stems from the fact that at random times, very few and in-between of them, the Shopify Function I’ve coded won’t detect the change of content of the attribute (which I gather from sharing the logs from the store and perusing them in my app).

Fact of the matter is the attribute is very much there if I query the storefront API cart but the Shopify Function won’t see the data, e.g. when I trigger a quantity change in the front-end right then and there

I get that it’s very much code-related and it’s tough for me to share anything small and reproducibile but any chance someone could shed some light into some kind of caching/peculiar case in which the attribute might find some kind of friction in getting set?

Reloading the page, which retriggers the attribute save via cartAttributesUpdate, almost always fixes the issue, but that’s something I can’t really be relying on

Thanks for the help