aws-amplify / aws-amplify/amplify-cli

Uploading the files of the web app to S3 should be in a different order

Open
#2,087 3 comments 3 reactions 1 assignee Claimed by @0618 View on GitHub
bug good first issue hosting p2
Dominant language
TypeScript
Stars
2.9k
Forks
825
Avg merge
11d 23h
Merged PRs (30d)
2

Description

>**Note**: If your issue/bug is regarding the AWS Amplify Console service, please log it in the
[Amplify Console GitHub Issue Tracker](https://github.com/aws-amplify/amplify-console/issues)

**Describe the bug**
We get the following error when deploying our app:
![image](https://user-images.githubusercontent.com/6344489/63282897-14574c00-c26d-11e9-8124-961775c44259.png)

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, the `index.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:

![image](https://user-images.githubusercontent.com/6344489/63283051-6ef0a800-c26d-11e9-8b4c-0902895dc94d.png)

**To Reproduce**
Steps to reproduce the behavior:
1. Upload the app.
2. This is a little harder to see if your internet is blazing fast, but if you can throttle it a little, then try to reload the page right after the `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, as `promise-sequential` which is a wrapper around `Promise.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):**
- OS: macOS
- Browser: Firefox
- Version: 68.0.1

**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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.