Bubble errors from the server to the client on suspense boundaries (#2772)

* Bubble errors from the server to the client on suspense boundaries

* make resolving suspense boundaries O(n)
This commit is contained in:
Evan Almloff authored and GitHub committed 2024-08-02 19:01:55 -07:00
1 parent 3003362b52
commit b0a2e2418c
12 files changed
+190 -39

No files matched your search

+6 -1
View File
@@ -138,7 +138,12 @@ impl WebsysDom {
self.interpreter.base().push_root(node);
}
with_server_data(HTMLDataCursor::from_serialized(&data), || {
let server_data = HTMLDataCursor::from_serialized(&data);
// If the server serialized an error into the suspense boundary, throw it on the client so that it bubbles up to the nearest error boundary
if let Some(error) = server_data.error() {
dom.in_runtime(|| id.throw_error(error));
}
with_server_data(server_data, || {
// rerun the scope with the new data
SuspenseBoundaryProps::resolve_suspense(
id,