Action get_persisted_item has exceeded the rate limit

Environment

SDK Version: @shopify/shop-minis-react@0.14.0
CLI Version: @shopify/shop-minis-cli@0.3.5
Device: Android Simulator (Pixel 3)
Development OS: Debian Linux
Mini Handle: foodsocial-recipes

Issue

What’s broken: I get an error about exceeding rate limits for get_persisted_item on local dev builds.
Expected behavior:
Actual behavior:
Error message: action get_persisted_item has exceeded the rate limit of 100 requests per 60s. The limits may vary in production.

Reproduction steps

  1. Run our app. Usually the error popup happens within a few clicks

Already Tried

  • First and foremost: have I read the docs? Yes - I can’t find any reference to get_persisted_item

  • Confirmed scopes match what I’m accessing: only scope is user_settings:read. (after a recent upgrade, it had me remove products:recent:read and product_list:write; maybe those have become default permissions?)

  • I’ve run npx shop-minis upgrade to make sure I’m on the latest versions: yes.

This is an existing app, written by a former coworker. I don’t know if this error has been happening all the time or not. I didn’t make any changes other than what the linter and upgrade required. I submitted the app last night. I assume the production limits are higher than the dev limits, so the error doesn’t apply to production?

Since I’m new to the code, I could use a reference to how our app is calling get_persisted_item - asyncStorage?

thanks.

Hi,

get_persisted_item is the action used by getItem method in the Async Storage hook: useAsyncStorage.

This error would mean that you are calling that method 100+ times in a single minute, which is most likely due to a React re-rendering bug on the Mini. I’d suggest adding some logs and debugging calls to this getItem method.

Thanks

1 Like

Looking now, thanks.

We have the user’s saved favorites in a for loop, calling getItem for each one, and then my guess that the answer isn’t cached, so maybe the for loop gets called on each page view.

I have one link to dev docs, but apparently not to the right place, as getItem returns 0 results. (I was hoping there was a getItems() function or something, but in any case, having a good link to where the functions are defined would be good.

I’ve added a cache to getItem, and that is working much better. Now that I’m clicking around a lot, I also triggered a REPORT_FETCH limit as well. What function uses that?

I’d still like the answer to the REPORT_FETCH question, but I’ve submitted a new mini that solves the getItem problem, along with other regressions that this last version added, so it’d be great to get this published as soon as possible. Thanks.

Hi @jondaley

For getItem, I’d suggest keeping a dictionary as the value, and not create a different key for each favourite a user has. If you are having to make 100+ reads in a single minute, then there is something wrong with the design and we’d love to hear more about your use case.

As for REPORT_FETCH, that’s triggered on each network request your Mini does. You would only see that if you are making 100+ network requests in a single minute.

This sounds like there are various re-rendering issues with your Mini at the moment and these need to be resolved in the next submission.

Thanks

1 Like