Azure / static-web-apps

Azure Static Web Apps. For bugs and feature requests, please create an issue in this repo. For community discussions, latest updates, kindly refer to the Discussions Tab. To know what's new in Static Web Apps, visit https://aka.ms/swa/ThisMonth
https://aka.ms/swa
MIT License
318 stars 53 forks source link

Requests intermittently reaching the previous/latest versions of an SWA application immediately after deploying a new version. #1472

Open arrow-dev opened 1 month ago

arrow-dev commented 1 month ago

After deploying a new version of an Angular application to an SWA instance and visiting the URL, requests seem to intermittently be routed to either the old or new version of the SWA causing hashed JS and CSS bundles to be missing/trigger the navigationFallback rule to rewrite response to index.html

SWA Issue Flowchart

To Reproduce Steps to reproduce (intermittent):

  1. Deploy new version of app
  2. Vist app URL
  3. Inspect network log to see that the index.html is the correct/latest version referencing the latest bundles but at random one or more of the bundles have triggered the navigationRewrite rule and are populated with the previous index.html instead of the expected js/css

Notes:

I'm aware this should also have an exclude files clause - which would prevent these from being re-written to index.html - however it doesn't seem like adding this would fix the high level issue and instead would just return 404's for the files? If this is not the case, and this would actually fix the issue for some reason it would be good to understand why. (ie if the missing files didn't trigger the fallback rule would the SWA infrastructure then check elsewhere for them (and find them) rather than immediately return a 404 to the browser?)

Expected behaviour After deploying a new build, a user trying to access the app should be able to do so without any issues loading the assets.