Skip to content

fix: catch synchronous error #2476

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 16, 2025
Merged

Conversation

juanrgm
Copy link
Contributor

@juanrgm juanrgm commented May 9, 2025

Summary

Synchronous (non-promise) errors cannot be caught by ErrorBoundary.

https://playground.solidjs.com/anonymous/98e1258d-67c8-4c53-b9cb-4bfa029d451e

import { render } from "solid-js/web";
import { ErrorBoundary, createResource } from "solid-js";

function Counter() {
  const [res] = createResource(() => {
    if (1) throw new Error(); // this error is not captured by ErrorBoundary
    return 1;
  });

  return (
    <ErrorBoundary fallback={(error) => <>{error.toString()}</>}>
      {res()}
    </ErrorBoundary>
  );
}

render(() => <Counter />, document.getElementById("app")!);

Using an async function as fetcher it works:

https://playground.solidjs.com/anonymous/0e5e5348-57ef-41b3-aebf-66f8567122c8

How did you test this change?

An unit test was added to the commit.

Copy link

changeset-bot bot commented May 9, 2025

🦋 Changeset detected

Latest commit: 1441227

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
solid-js Patch
test-integration Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coveralls
Copy link

Pull Request Test Coverage Report for Build 14923115814

Details

  • 15 of 15 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.6%) to 85.752%

Totals Coverage Status
Change from base Build 14767323724: 0.6%
Covered Lines: 2333
Relevant Lines: 2652

💛 - Coveralls

@ryansolid ryansolid merged commit 4cd7eb1 into solidjs:main May 16, 2025
1 check passed
@ryansolid
Copy link
Member

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants