Giter Site home page Giter Site logo

Comments (9)

kraenhansen avatar kraenhansen commented on June 21, 2024 1

We agree an error like this should signaled differently than calling console.error:

  1. Calling onError would be difficult, because that function takes the active sync session, but at this point no sync session has been established. To call it, we would have to break the API, allowing the onError to have null passed as the sync session argument, which is not ideal. So .. since this error isn't sync specific, we would most likely want to surface it differently than though the onError.
  2. The RealmProvider could take an onError prop (admittedly, this name might be a little confusing as it conflicts with the onError passed through the sync config).
  3. We could throw when the useRealm (or any of our other hooks depending on it).
  4. Some other alternative that we haven't thought of? What's an idiomatic way to signal an error state from a React context provider? 🤔

from realm-js.

gfrancischini avatar gfrancischini commented on June 21, 2024 1

The RealmProvider could take an onError prop (admittedly, this name might be a little confusing as it conflicts with the onError passed through the sync config).

I would call it onInitializeError or onRealmInitializeError as this is something that will only happen during realm initialization?

Or maybe onMountError? but I still prefer the above

We could throw when the useRealm (or any of our other hooks depending on it).
I think this is bad as it is not good to handle error on component renders

from realm-js.

gfrancischini avatar gfrancischini commented on June 21, 2024 1

I feel that error boundaries should be used when something unexpectedly happens. A schema error is a handled error and in my opinion, should be handled differently. What we know/is expected should be handled different from the unknow.

But that is only my opinion really. So whatever solutions as long as we can show to our end user it is okay. What we cannot do is swallow the error as it is today as the app just crashes without giving user feedback

from realm-js.

sync-by-unito avatar sync-by-unito commented on June 21, 2024

➤ PM Bot commented:

Jira ticket: RJS-2794

from realm-js.

kneth avatar kneth commented on June 21, 2024

@gfrancischini Thank you for reporting.

I believe that we should extend @realm/react with an option not to shallow the exceptions from Realm.open(). We can either rethrow the exception or call the onError callback (if defined).

from realm-js.

gfrancischini avatar gfrancischini commented on June 21, 2024

Hey any update on this issue? We are about to enter in homologation with our customer and we would like to be able to correctly log these errors to diagnose possible production problems

from realm-js.

kneth avatar kneth commented on June 21, 2024

@gfrancischini

any update on this issue?

Currently we are logging the errors to help customers to diagnose problems. To provide a better solution, we would like the customer to give us feedback on the four items in the previous comment.

from realm-js.

kraenhansen avatar kraenhansen commented on June 21, 2024

I think this is bad as it is not good to handle error on component renders

I would expect developers to use an error boundary to handle these errors: Via getDerivedStateFromError on a class-based component or the resuable ErrorBoundary utility component.

from realm-js.

kraenhansen avatar kraenhansen commented on June 21, 2024

I suppose the difference is if it's recoverable for the end-user or not 🤔 Some will be, others likely wont. I think this decision is the only thing holding back a fix for this. It's likely a simple change in code - and I'd like for us to get the API right 👍

from realm-js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.