Skip to content

Commit

Permalink
Fix infinite loop in Suspense error handling on the server (#1649)
Browse files Browse the repository at this point in the history
  • Loading branch information
thetarnav committed Mar 26, 2023
1 parent 620c763 commit 1d4d532
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions packages/solid/src/server/rendering.ts
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,6 @@ export function SuspenseList(props: {

export function Suspense(props: { fallback?: string; children: string }) {
let done: undefined | ((html?: string, error?: any) => boolean);
let clean: any;
const ctx = sharedConfig.context!;
const id = ctx.id + ctx.count;
const o = createOwner();
Expand All @@ -569,8 +568,8 @@ export function Suspense(props: { fallback?: string; children: string }) {
});
function runSuspense() {
setHydrateContext({ ...ctx, count: 0 });
o && cleanNode(o);
return runWithOwner(o!, () => {
cleanNode(o);
return runWithOwner(o, () => {
return createComponent(SuspenseContext.Provider, {
value,
get children() {
Expand All @@ -584,14 +583,14 @@ export function Suspense(props: { fallback?: string; children: string }) {
// never suspended
if (suspenseComplete(value)) return res;

onError(err => {
if (!done || !done(undefined, err)) {
if (o)
runWithOwner(o.owner!, () => {
runWithOwner(o, () => {
onError(err => {
if (!done || !done(undefined, err)) {
runWithOwner(o.owner, () => {
throw err;
});
else throw err;
}
}
});
});
done = ctx.async ? ctx.registerFragment(id) : undefined;
if (ctx.async) {
Expand Down

0 comments on commit 1d4d532

Please sign in to comment.