123456789101112131415161718192021222324 |
- import {isWebpackChunkLoadingError} from 'sentry/utils';
- const MAX_RETRIES = 2;
- export default async function retryableImport<T>(
- fn: () => Promise<{default: T}>
- ): Promise<T> {
- let retries = 0;
- const tryLoad = async () => {
- try {
- const module = await fn();
- return module.default ?? module;
- } catch (err) {
- if (isWebpackChunkLoadingError(err) && retries < MAX_RETRIES) {
- retries++;
- return tryLoad();
- }
- throw err;
- }
- };
- return tryLoad();
- }
|