Skip to content

Skip the background notifications fetch while the cache is fresh - #9046

Open
hasandenizuk wants to merge 1 commit into
Shopify:mainfrom
hasandenizuk:perf/skip-fresh-notifications-fetch
Open

hasandenizuk wants to merge 1 commit into
Shopify:mainfrom
hasandenizuk:perf/skip-fresh-notifications-fetch

Conversation

@hasandenizuk

Copy link
Copy Markdown

WHY are these changes introduced?

After every command, the prerun hook starts shopify notifications list --ignore-errors as a detached process. That process boots the whole CLI again: on CLI 5.0.0 it takes about 2.4 s and 2.5 to 3 s of CPU, more than a short command like shopify version (about 1.4 s of CPU). Scripts that run many short commands, for example a loop of shopify store execute calls, pay this on every call, and in parallel runs these background processes take the CPU the real calls need.

WHAT is this pull request doing?

fetchNotificationsInBackground now reads the timestamp the notifications cache already stores, and skips the background fetch when the cached list is less than an hour old. After an hour, or with an empty cache, it fetches as before. Two unit tests cover a fresh and a stale cache.

How to manually test your changes?

Run shopify version --verbose twice in a row. Before: both runs start the background notifications process. After: the second run does not, until an hour has passed since the last fetch.

Checklist

  • I've considered possible cross-platform impacts (Mac, Linux, Windows)
  • I've considered possible documentation changes
  • I've considered analytics changes to measure impact
  • The change is user-facing — I've identified the correct bump type (patch for bug fixes · minor for new features · major for breaking changes) and added a changeset with pnpm changeset add

@hasandenizuk
hasandenizuk requested a review from a team as a code owner October 29, 2026 21:00
@hasandenizuk

Copy link
Copy Markdown
Author

I have signed the CLA!

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant