Skip to content

2.0.0-beta.4 Errors break SSR/Hydration #2651

@rvlzzr

Description

@rvlzzr

Describe the bug

Error fallback does not show on initial load with streaming SSR + hydration. Works correctly on client navigation.

In this example I see two "Item loading..." for 1.5 seconds as expected, but then only a single "Test Item" and no ItemError.

Browser console shows:

Uncaught (in promise) Error: Item bad-item not found
    at loadItem (home/.../src/routes/test.tsx:5:30)
import { createMemo, Errored, Loading } from "solid-js";

async function loadItem(id: string) {
  await new Promise((resolve) => setTimeout(resolve, 1500));
  if (id !== "1") throw new Error(`Item ${id} not found`);
  return { title: "Test Item" };
}

function Item(props: { id: string }) {
  const item = createMemo(() => loadItem(props.id));

  return (
    <Loading fallback={<div>Item Loading...</div>}>
      <Errored fallback={(e) => <div>ItemError: {String(e)}</div>}>
        <div>{item().title}</div>
      </Errored>
    </Loading>
  );
}

export default function Test() {
  return (
    <div>
      <Item id="1" />
      <Item id="bad-item" />
    </div>
  );
}

Your Example Website or App

Steps to Reproduce the Bug or Issue

Expected behavior

Screenshots or Videos

No response

Platform

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions