Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
try {
const manifest = await callApi(url, method); // eslint-disable-line no-await-in-loop
return manifest;
} catch (e) {
const statusCode = e.response && e.response.status;
setScreen({ type: 'loading', text: 'Bundling Dependencies...' });
// 403 status code means the bundler is still bundling
if (retries < RETRY_COUNT && statusCode === 403) {
retries += 1;
await delay(1000 * 2); // eslint-disable-line no-await-in-loop
} else if (retries < RETRY_COUNT && statusCode === 500) {
dispatch(
actions.notifications.show(
'It seems like all packagers are busy, retrying in 10 seconds...',
'warning'
)
);
await delay(1000 * 2); // eslint-disable-line no-await-in-loop
retries += 1;
} else {
throw e;
}
}
}
}
npmDependencies: Dependencies,
resolutions?: { [key: string]: string }
) {
if (Object.keys(npmDependencies).length !== 0) {
// New Packager flow
try {
const result = await getDependencies(npmDependencies);
setScreen({ type: 'loading', text: 'Transpiling Modules...' });
return result;
} catch (e) {
e.message = `Could not fetch dependencies, please try again in a couple seconds: ${
e.message
}`;
dispatch(actions.notifications.show(e.message, 'error'));
throw e;
}
}
return false;
}
async function requestPackager(url, method = 'GET') {
let retries = 0;
dispatch(actions.notifications.show('Bundling dependencies...'));
// eslint-disable-next-line no-constant-condition
while (true) {
debug(`Trying to call packager for ${retries} time`);
try {
const manifest = await callApi(url, method); // eslint-disable-line no-await-in-loop
return manifest;
} catch (e) {
const statusCode = e.response && e.response.status;
setScreen({ type: 'loading', text: 'Bundling Dependencies...' });
// 403 status code means the bundler is still bundling
if (retries < RETRY_COUNT && statusCode === 403) {
retries += 1;
await delay(1000 * 2); // eslint-disable-line no-await-in-loop