-
Since a few weeks I've been catching errors with the ErrorBoundary. I've added a little post request, to report that an error has occurred. Now I noticed that after a new deployment (which happens at night), that a lot of errors occur the morning after. This only seems the case when the data format from the loader has changed. Therefore my assumption is that the javascript code is cached or data is requested via the fetcher and thus not SSR. Is there any way to (automatically) force the user's browser to update the javascript files and prevent such errors? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 6 replies
-
I need solving this problem also. Did you ever find a good solution @Marcdj-02 ? |
Beta Was this translation helpful? Give feedback.
-
Remix doesn't provide a way to do this, but you can do it yourself. First, the problem happens not because JS is cached, but because you have users that are not closing the app, if the user A opens your app today and never close the tab in a week, it will keep using the old version of JS, which can expect a different loader data shape. Aside of the recommendation to try to avoid changing the shape of the loader's data in a way that's incompatible with old version (aka always add keys, never remove them), you will need to detect the current version of the JS client-side and the current version of the JS server-side. Client-side, you can access this value You can then expose the server build version from a resource route (e.g. I would recommend you to tell the user to do it, in case they're working on some form and you want to ensure they don't lose any data (unless you keep the draft data in localStorage). Another option could be to add the |
Beta Was this translation helpful? Give feedback.
Remix doesn't provide a way to do this, but you can do it yourself.
First, the problem happens not because JS is cached, but because you have users that are not closing the app, if the user A opens your app today and never close the tab in a week, it will keep using the old version of JS, which can expect a different loader data shape.
Aside of the recommendation to try to avoid changing the shape of the loader's data in a way that's incompatible with old version (aka always add keys, never remove them), you will need to detect the current version of the JS client-side an…