Skip to content

Commit 671f64b

Browse files
authored
fix: download retrieves count per file (#2354)
1 parent c5c8d45 commit 671f64b

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

.changeset/mean-months-sparkle.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@module-federation/native-federation-typescript': patch
3+
'@module-federation/native-federation-tests': patch
4+
---
5+
6+
download retrieves count per file

packages/native-federation-tests/src/lib/archiveHandler.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,12 @@ const downloadErrorLogger =
2727
};
2828

2929
export const downloadTypesArchive = (hostOptions: Required<HostOptions>) => {
30-
let retries = 0;
30+
const retriesPerFile: Record<string, number> = {};
3131
return async ([destinationFolder, fileToDownload]: string[]) => {
32+
retriesPerFile[fileToDownload] = 0;
3233
const destinationPath = join(hostOptions.mocksFolder, destinationFolder);
3334

34-
while (retries++ < hostOptions.maxRetries) {
35+
while (retriesPerFile[fileToDownload]++ < hostOptions.maxRetries) {
3536
try {
3637
const response = await axios
3738
.get(fileToDownload, { responseType: 'arraybuffer' })
@@ -48,7 +49,7 @@ export const downloadTypesArchive = (hostOptions: Required<HostOptions>) => {
4849
}`,
4950
),
5051
);
51-
if (retries >= hostOptions.maxRetries) {
52+
if (retriesPerFile[fileToDownload] >= hostOptions.maxRetries) {
5253
throw error;
5354
}
5455
}

packages/native-federation-typescript/src/lib/archiveHandler.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,12 @@ const downloadErrorLogger =
3737
};
3838

3939
export const downloadTypesArchive = (hostOptions: Required<HostOptions>) => {
40-
let retries = 0;
40+
const retriesPerFile: Record<string, number> = {};
4141
return async ([destinationFolder, fileToDownload]: string[]) => {
42+
retriesPerFile[fileToDownload] = 0;
4243
const destinationPath = join(hostOptions.typesFolder, destinationFolder);
4344

44-
while (retries++ < hostOptions.maxRetries) {
45+
while (retriesPerFile[fileToDownload]++ < hostOptions.maxRetries) {
4546
try {
4647
const response = await axios
4748
.get(fileToDownload, { responseType: 'arraybuffer' })
@@ -58,7 +59,7 @@ export const downloadTypesArchive = (hostOptions: Required<HostOptions>) => {
5859
}`,
5960
),
6061
);
61-
if (retries >= hostOptions.maxRetries) {
62+
if (retriesPerFile[fileToDownload] >= hostOptions.maxRetries) {
6263
throw error;
6364
}
6465
}

0 commit comments

Comments
 (0)