Files
outline/app/utils/lazyWithRetry.test.ts
T
Tom Moor 26f6ed96f0 fix: Recover from mismatched chunks after a deploy (#13489)
A dynamic import can resolve to a chunk from a different build, throwing
"does not provide an export named", which was not recognized as a chunk
error. Share one stale chunk matcher between the lazy import retry, the
error boundary, and Sentry so all three treat it as recoverable.

Fixes OUTLINE-CLOUD-D1M
2026-08-19 08:06:26 -04:00

39 lines
1.1 KiB
TypeScript

import { isStaleChunkError } from "./lazyWithRetry";
describe("isStaleChunkError", () => {
it("matches a chunk that could not be fetched", () => {
expect(
isStaleChunkError(
new TypeError(
"Failed to fetch dynamically imported module: https://example.com/Editor.abc123.js"
)
)
).toBe(true);
});
it("matches a module script that failed to import", () => {
expect(
isStaleChunkError(new TypeError("Importing a module script failed."))
).toBe(true);
});
it("matches a chunk with a missing export", () => {
expect(
isStaleChunkError(
new SyntaxError(
"The requested module './PluginIcon.BGMce7FN.js' does not provide an export named 't'"
)
)
).toBe(true);
});
it("matches a non-error value", () => {
expect(isStaleChunkError("Importing a module script failed.")).toBe(true);
});
it("does not match an unrelated error", () => {
expect(isStaleChunkError(new Error("Something went wrong"))).toBe(false);
expect(isStaleChunkError(undefined)).toBe(false);
});
});