Skip to content

Commit

Permalink
fix: surface errors to the proper error boundary after _internalSetRo…
Browse files Browse the repository at this point in the history
…utes
  • Loading branch information
jacob-ebey committed May 2, 2023
1 parent c4e9607 commit 4a053ef
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 9 deletions.
5 changes: 5 additions & 0 deletions .changeset/hmr-error-boundary.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@remix-run/router": patch
---

surface errors to the proper error boundary after \_internalSetRoutes
17 changes: 9 additions & 8 deletions packages/router/__tests__/router-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15351,7 +15351,7 @@ describe("a router", () => {

// Routes should be updated
expect(t.router.routes).not.toBe(ogRoutes);
expect(t.router.routes).toBe(newRoutes);
expect(t.router.routes).toEqual(newRoutes);

// Loader data should be updated and foo removed
expect(t.router.state.loaderData).toEqual({
Expand Down Expand Up @@ -15401,7 +15401,7 @@ describe("a router", () => {

// Routes should be updated
expect(t.router.routes).not.toBe(ogRoutes);
expect(t.router.routes).toBe(newRoutes);
expect(t.router.routes).toEqual(newRoutes);

// Loader data should be updated
expect(t.router.state.loaderData).toEqual({
Expand Down Expand Up @@ -15467,7 +15467,7 @@ describe("a router", () => {

// Routes should be updated
expect(t.router.routes).not.toBe(ogRoutes);
expect(t.router.routes).toBe(newRoutes);
expect(t.router.routes).toEqual(newRoutes);

// Loader data should be updated
expect(t.router.state.loaderData).toEqual({
Expand Down Expand Up @@ -15527,7 +15527,7 @@ describe("a router", () => {

// Routes should be updated
expect(t.router.routes).not.toBe(ogRoutes);
expect(t.router.routes).toBe(newRoutes);
expect(t.router.routes).toEqual(newRoutes);

// Loader data should be updated
expect(t.router.state.loaderData).toEqual({
Expand Down Expand Up @@ -15582,8 +15582,8 @@ describe("a router", () => {
{
path: "/",
id: "root",
hasErrorBoundary: true,
loader: () => rootDfd2.promise,
hasErrorBoundary: true,
children: [
{
index: true,
Expand Down Expand Up @@ -15616,7 +15616,7 @@ describe("a router", () => {

// Routes should be updated
expect(currentRouter.routes).not.toEqual(ogRoutes);
expect(currentRouter.routes).toBe(newRoutes);
expect(currentRouter.routes).toEqual(newRoutes);

// Loader data should be updated
expect(currentRouter.state.loaderData).toEqual({
Expand Down Expand Up @@ -15684,12 +15684,13 @@ describe("a router", () => {
{
path: "/",
id: "root",
hasErrorBoundary: true,
loader: () => rootDfd2.promise,
hasErrorBoundary: true,
children: [
{
index: true,
id: "index",
hasErrorBoundary: false,
},
],
},
Expand All @@ -15711,7 +15712,7 @@ describe("a router", () => {

// Routes should be updated
expect(currentRouter.routes).not.toEqual(ogRoutes);
expect(currentRouter.routes).toBe(newRoutes);
expect(currentRouter.routes).toEqual(newRoutes);

// Loader data should be updated
expect(currentRouter.state.loaderData).toEqual({
Expand Down
8 changes: 7 additions & 1 deletion packages/router/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2474,7 +2474,13 @@ export function createRouter(init: RouterInit): Router {
}

function _internalSetRoutes(newRoutes: AgnosticDataRouteObject[]) {
inFlightDataRoutes = newRoutes;
manifest = {};
inFlightDataRoutes = convertRoutesToDataRoutes(
newRoutes,
mapRouteProperties,
undefined,
manifest
);
}

router = {
Expand Down

0 comments on commit 4a053ef

Please sign in to comment.