Skip to content

Commit

Permalink
Proxy server loader errors through serverLoader during hydration (#8304)
Browse files Browse the repository at this point in the history
  • Loading branch information
brophdawg11 committed Dec 15, 2023
1 parent 37ee74e commit f97105b
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions integration/client-data-test.ts
@@ -1,5 +1,6 @@
import { test, expect } from "@playwright/test";

import { ServerMode } from "../packages/remix-server-runtime/mode.js";
import {
createAppFixture,
createFixture,
Expand Down Expand Up @@ -724,6 +725,61 @@ test.describe("Client Data", () => {
html = await app.getHtml("main");
expect(html).toMatch("Child Server Loader Data (2+) (mutated by client)");
});

test("server loader errors are re-thrown from serverLoader()", async ({
page,
}) => {
let _consoleError = console.error;
console.error = () => {};
appFixture = await createAppFixture(
await createFixture(
{
files: {
...getFiles({
parentClientLoader: false,
parentClientLoaderHydrate: false,
childClientLoader: false,
childClientLoaderHydrate: false,
}),
"app/routes/parent.child.tsx": js`
import { ClientLoaderFunctionArgs, useRouteError } from "@remix-run/react";
export function loader() {
throw new Error("Broken!")
}
export async function clientLoader({ serverLoader }) {
return await serverLoader();
}
clientLoader.hydrate = true;
export default function Index() {
return <h1>Should not see me</h1>;
}
export function ErrorBoundary() {
let error = useRouteError();
return <p id="child-error">{error.message}</p>;
}
`,
},
},
ServerMode.Development // Avoid error sanitization
),
ServerMode.Development // Avoid error sanitization
);
let app = new PlaywrightFixture(appFixture, page);

await app.goto("/parent/child");
let html = await app.getHtml("main");
expect(html).toMatch("Broken!");
// Ensure we hydrate and remain on the boundary
await new Promise((r) => setTimeout(r, 100));
html = await app.getHtml("main");
expect(html).toMatch("Broken!");
expect(html).not.toMatch("Should not see me");
console.error = _consoleError;
});
});

test.describe("clientLoader - lazy route module", () => {
Expand Down

0 comments on commit f97105b

Please sign in to comment.