Skip to content

Commit

Permalink
chore(retry-plugin): remove unnecessary null-check before calling bef…
Browse files Browse the repository at this point in the history
…oreExecuteRetry (#3361)

Co-authored-by: Karina <[email protected]>
  • Loading branch information
haesoo-y and danpeen authored Dec 16, 2024
1 parent f7983f9 commit 1ba0c16
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/retry-plugin/src/fetch-retry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ async function fetchWithRetry({
} catch (error) {
if (retryTimes <= 0) {
logger.log(
`[ Module Federation RetryPlugin ]: retry failed after ${retryTimes} times for url: ${url}, now will try fallbackUrl url`,
`${PLUGIN_IDENTIFIER}: retry failed after ${retryTimes} times for url: ${url}, now will try fallbackUrl url`,
);

if (fallback && typeof fallback === 'function') {
Expand Down
10 changes: 7 additions & 3 deletions packages/retry-plugin/src/util.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { defaultRetries, defaultRetryDelay } from './constant';
import {
defaultRetries,
defaultRetryDelay,
PLUGIN_IDENTIFIER,
} from './constant';
import type { ScriptCommonRetryOption } from './types';
import logger from './logger';

Expand All @@ -22,7 +26,7 @@ export function scriptCommonRetry<T extends (...args: any[]) => void>({
let attempts = 0;
while (attempts - 1 < retryTimes) {
try {
beforeExecuteRetry && beforeExecuteRetry();
beforeExecuteRetry();
retryResponse = await retryFn(...args);
break;
} catch (error) {
Expand All @@ -36,7 +40,7 @@ export function scriptCommonRetry<T extends (...args: any[]) => void>({
throw error;
}
logger.log(
`[ Module Federation RetryPlugin ]: script resource retrying ${attempts} times`,
`${PLUGIN_IDENTIFIER}: script resource retrying ${attempts} times`,
);
await new Promise((resolve) => setTimeout(resolve, retryDelay));
}
Expand Down

0 comments on commit 1ba0c16

Please sign in to comment.