mirror of
https://github.com/outline/outline.git
synced 2026-12-03 01:59:03 +03:00
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
39 lines
1.1 KiB
TypeScript
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);
|
|
});
|
|
});
|