Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion packages/solid/src/server/signals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -935,7 +935,14 @@ function serverEffect<T>(
}
effectFn?.((ssrSource ? (comp.value ?? result) : result) as any, undefined);
} catch (err) {
// Swallow errors from effects on server
// NotReadyError is suspense control flow — must keep propagating so the
// surrounding Loading boundary can react. For real errors, record on the
// computation and re-throw so a wrapping `createErrorBoundary` /
// `<Errored>` can catch instead of the error vanishing into the void
// (#2777).
if (err instanceof NotReadyError) throw err;
comp.error = err;
throw err;
}
}

Expand Down
21 changes: 21 additions & 0 deletions packages/solid/test/server/signals.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,27 @@ describe("Server createErrorBoundary", () => {
{ id: "test" }
);
});

test("catches errors thrown from createEffect on the server (#2777)", () => {
createRoot(
() => {
const result = createErrorBoundary(
() => {
createEffect(
() => {
throw new Error("server effect boom");
},
() => {}
);
return "children";
},
(err: () => unknown) => `caught: ${(err() as Error).message}`
);
expect(result()).toBe("caught: server effect boom");
},
{ id: "test" }
);
});
});

// === createLoadingBoundary ===
Expand Down