All files / app/services/app-update is-chunk-load-error.ts

100% Statements 8/8
100% Branches 8/8
100% Functions 2/2
100% Lines 7/7

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 184x                 4x 16x 4x   12x 12x 47x    
const CHUNK_ERROR_PATTERNS: readonly RegExp[] = [
    /Loading chunk \S+ failed/i,
    /Loading CSS chunk \S+ failed/i,
    /Failed to fetch dynamically imported module/i,
    /error loading dynamically imported module/i,
    /Importing a module script failed/i,
    /ChunkLoadError/i,
];
 
export function isChunkLoadError(error: unknown): boolean {
    if (!error || typeof error !== 'object') {
        return false;
    }
    const { name, message } = error as { name?: unknown; message?: unknown };
    const haystack = [typeof name === 'string' ? name : '', typeof message === 'string' ? message : ''].join(' ');
    return CHUNK_ERROR_PATTERNS.some(pattern => pattern.test(haystack));
}