File tree Expand file tree Collapse file tree 2 files changed +39
-1
lines changed Expand file tree Collapse file tree 2 files changed +39
-1
lines changed Original file line number Diff line number Diff line change @@ -13731,6 +13731,45 @@ describe("a router", () => {
1373113731 );
1373213732 consoleWarn.mockReset();
1373313733 });
13734+
13735+ it("handles errors thrown from static loaders before lazy has completed", async () => {
13736+ let consoleWarn = jest.spyOn(console, "warn");
13737+ let t = setup({
13738+ routes: [
13739+ {
13740+ id: "root",
13741+ path: "/",
13742+ children: [
13743+ {
13744+ id: "lazy",
13745+ path: "lazy",
13746+ loader: true,
13747+ lazy: true,
13748+ },
13749+ ],
13750+ },
13751+ ],
13752+ });
13753+
13754+ let A = await t.navigate("/lazy");
13755+
13756+ await A.loaders.lazy.reject("STATIC LOADER ERROR");
13757+ expect(t.router.state.navigation.state).toBe("loading");
13758+
13759+ // We shouldn't bubble the loader error until after this resolves
13760+ // so we know if it has a boundary or not
13761+ await A.lazy.lazy.resolve({
13762+ hasErrorBoundary: true,
13763+ });
13764+ expect(t.router.state.location.pathname).toBe("/lazy");
13765+ expect(t.router.state.navigation.state).toBe("idle");
13766+ expect(t.router.state.loaderData).toEqual({});
13767+ expect(t.router.state.errors).toEqual({
13768+ lazy: "STATIC LOADER ERROR",
13769+ });
13770+
13771+ consoleWarn.mockReset();
13772+ });
1373413773 });
1373513774
1373613775 describe("interruptions", () => {
Original file line number Diff line number Diff line change @@ -3645,7 +3645,6 @@ async function callLoaderOrAction(
36453645 // Run statically defined handler in parallel with lazy()
36463646 let handlerError ;
36473647 let values = await Promise . all ( [
3648- // TODO: Write test for this
36493648 // If the handler throws, don't let it immediately bubble out,
36503649 // since we need to let the lazy() execution finish so we know if this
36513650 // route has a boundary that can handle the error
You can’t perform that action at this time.
0 commit comments