App loads twice

On initial page load, the loader in the route app._index is called twice, resulting in the functions in that loader to also be called twice.

The highlighted line is before the page is manually refreshed. Also note the timestamps

When refreshing on another route ( app/invoice ) the issue doesn’t occur, note the "Big function called" log as an indicator. Which is a function called on the app._index route loader.

I checked if this was an issue on the regular Remix template

Refreshing on route /app:
429247416-bc8591a4-cd1d-40e3-a11f-5987f1630fc8

Refreshing on route /app/invoice:
429247424-5022944a-0030-432f-a00d-2292d86f761a

Reproduction:
Setup Shopify remix app template
Then only changed the routes, adding the console.log

I’ve uploaded the repo here


This issue was originally posted in the Remix template issues, here

Unfortuantely, it was closed, the reason here. However, after some discoveries I decided to repost it here since the maintainer seems to be unavailable. So the isuse can hopefully be investigated.

I believe this issue started happening between March 27th-30th (2025). As my endpoint to receive APP_SUBSCRIPTIONS_UPDATE webhooks sends me emails. And between those dates, I started receiving two of the same email.

Anyways, I also discovered footage of back in September 24, that indirectly demonstrates that it wasn’t an issue back then and that its a new issue.
Please view here

Possible related issues:
GH Shopify App Bridge Issue 498

As far as I understand it this has to do with preloading magic shopify does.

Afaik this is what’s resulting in your app being called twice.

Kevin :hatching_chick:

Hey Kevin,

My thoughts exactly, definitely some kind of preloading. I just hope some kind of change can be made where it isn’t so impactful to the DX

Edit:
I’ve noticed the error Blocked script execution in <URL> because the document’s frame is sandboxed and the ‘allow-scripts’ permission is not set since June 2024, so I don’t think its related.

The issue seems to be resolved now

Apologies for flip flopping this topic, but I thought I should update this as the issue has returned. It seems to be on and off, so I’m guessing the dev team is aware of the issue?

Disregard my previous message about this error:
Blocked script execution in <URL> because the document’s frame is sandboxed and the ‘allow-scripts’ permission is not set

Kevin may be right, as when the error went away, that error message didn’t appear in the console. It still appears currently.

Hey @Taj_Bowness,

im pretty sure all of this is intended behaviour at the moment.

Kevin :hatching_chick:

I’m afraid you might be right. I’m just hoping someone from Shopify could clarify on this behaviour so I can decide how to proceed.

If it were to stay, I hope they can consider attaching something to the request so it can be identified. As I have a loader that calls a large function–so it would be useful to be able to shake that second request in that loader.