Skip to content

Commit

Permalink
[labs/ssr-client] Provide better error message on hydration value mis…
Browse files Browse the repository at this point in the history
…match (#4481)
  • Loading branch information
augustjk authored Jan 9, 2024
1 parent fa73bbb commit 1a1f3f0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/few-garlics-dress.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@lit-labs/ssr-client': patch
---

Provide better error message in `createAttributeParts()` when an error occurs due to hydration value mismatch.
8 changes: 7 additions & 1 deletion packages/labs/ssr-client/src/lib/hydrate-lit-html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,13 @@ const createAttributeParts = (
state.templatePartIndex++;
}
} else {
throw new Error('internal error');
// TODO(augustjk): This message may need to be updated based on
// hydration strategy. See https://github.com/lit/lit/issues/1434
throw new Error(
`Hydration value mismatch: Primitive found where TemplateResult expected.` +
` This usually occurs due to conditional rendering that resulted in a ` +
`different value or template being rendered between the server and client.`
);
}
};

Expand Down

0 comments on commit 1a1f3f0

Please sign in to comment.