Open timoteialbu opened 5 years ago
@timoteialbu Thanks for reporting the issue looking at the code briefly and I saw that there is no special ordering being during file scan, extra handling for the index document should be added there here.
Would you be interested submitting a PR with test for this issue?
@timoteialbu Thanks for pointing this out. But I will re-label this as an enhancement instead of a bug. The CLI hosting feature uses a general approach for different frontend frameworks, and different application update workflows. Different updates can change different parts of your application, and if there's a mismatch between the index file and other files that it refers to due to an update, you will see this behavior. So uploading the index file last wouldn't resolve this issue in general. IMHO, the correct approach would be to display a page temporarily during an update, notifying the user to come back again after a few minutes util your app is completely updated in the hosting bucket.
Hi @timoteialbu ! We have a PR to mitigate your issue #12852 , but it's not ideal. We would suggest you to cache and versionize your app.
Describe the bug We get the following error when deploying our app:
This error happens for a brief 15-30 seconds, but its enough to give us less than 100% uptime.
The reason this happens is because of the order that files are uploaded in. Basically the
index.html
file is uploaded before the scripts that it requires are, so when a user refreshes the page in that upload time frame, theindex.html
file they receive references a script that is not in S3 yet and therefore it throws the error above.I added a console log in here https://github.com/aws-amplify/amplify-cli/blob/master/packages/amplify-category-hosting/lib/S3AndCloudFront/helpers/file-uploader.js#L65 and was able to observe this upload order:
To Reproduce Steps to reproduce the behavior:
index.html
file is uploaded and you will see the above behavior.Expected behavior I expect the
index.html
to be uploaded last so that all the resources it needs are available to it. Its not about the order above, aspromise-sequential
which is a wrapper aroundPromise.all
does not guarantee the order the promises are fulfilled in. So you probably need to upload everything else first and once that succeeds, upload the index.html file. I realize as I am typing this that maybe a non-react app while have a different entry point potentially, so maybe this is not the ideal solution for all use cases.Screenshots See above.
Desktop (please complete the following information):
Smartphone (please complete the following information): Did not test as this is not a browser/OS specific issue.
Additional context This is a reactjs app.
Is this something I could work on in case its not a priority? I would be more than happy to contribute as we have been using
amplify-cli
extensively at my company since December 2018.