Skip to content

Commit d9c9e24

Browse files
author
Ives van Hoorne
committed
Make npm downloading more descriptive
1 parent ce02b6b commit d9c9e24

File tree

1 file changed

+6
-16
lines changed

1 file changed

+6
-16
lines changed

packages/app/src/sandbox/npm/fetch-dependencies.js

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ function callApi(url: string, method = 'GET') {
4949
async function requestPackager(url, method = 'GET') {
5050
let retries = 0;
5151

52-
dispatch(actions.notifications.show('Bundling dependencies...'));
5352
// eslint-disable-next-line no-constant-condition
5453
while (true) {
5554
debug(`Trying to call packager for ${retries} time`);
@@ -58,24 +57,10 @@ async function requestPackager(url, method = 'GET') {
5857

5958
return manifest;
6059
} catch (e) {
61-
const statusCode = e.response && e.response.status;
62-
63-
setScreen({ type: 'loading', text: 'Bundling Dependencies...' });
64-
6560
// 403 status code means the bundler is still bundling
66-
if (retries < RETRY_COUNT && statusCode === 403) {
61+
if (retries < RETRY_COUNT) {
6762
retries += 1;
6863
await delay(1000 * 2); // eslint-disable-line no-await-in-loop
69-
} else if (retries < RETRY_COUNT && statusCode === 500) {
70-
dispatch(
71-
actions.notifications.show(
72-
'It seems like all packagers are busy, retrying in 10 seconds...',
73-
'warning'
74-
)
75-
);
76-
77-
await delay(1000 * 2); // eslint-disable-line no-await-in-loop
78-
retries += 1;
7964
} else {
8065
throw e;
8166
}
@@ -107,6 +92,8 @@ async function getDependencies(dependencies: Object) {
10792
);
10893
return bucketManifest;
10994
} catch (e) {
95+
dispatch(actions.notifications.show('Bundling dependencies...'));
96+
11097
// The dep has not been generated yet...
11198
const { url } = await requestPackager(
11299
`${PACKAGER_URL}/${dependencyUrl}`,
@@ -123,7 +110,10 @@ export default async function fetchDependencies(npmDependencies: Dependencies) {
123110
// New Packager flow
124111

125112
try {
113+
dispatch(actions.notifications.show('Downloading dependencies...'));
126114
const result = await getDependencies(npmDependencies);
115+
setScreen({ type: 'loading', text: 'Transpiling...' });
116+
dispatch(actions.notifications.show('Dependencies loaded!', 'success'));
127117

128118
return result;
129119
} catch (e) {

0 commit comments

Comments
 (0)