Giter Site home page Giter Site logo

Comments (14)

njannink avatar njannink commented on July 23, 2024

I guess the element is null here somehow

const modalBody = element.querySelector('.modal-body');

from blazorise.

njannink avatar njannink commented on July 23, 2024

Possible a race condition here when disposing/navigating away.

await JSModalModule.OpenModal( ElementRef, ScrollToTop );

from blazorise.

stsrki avatar stsrki commented on July 23, 2024

We would probably need to add a null check on a bunch of places.

from blazorise.

David-Moreira avatar David-Moreira commented on July 23, 2024

Yep as we've seen most of the js exceptions are just race conditions where the element has disappeared when something was about to be invoked.

Again I'd probably not only add the null check but also the try/catch all we've talked about on some other thread. I know try/catching all might seem not like a good idea, but realistically do we ever want to stop an user's application with one of these js exceptions?

from blazorise.

njannink avatar njannink commented on July 23, 2024

biggest issue with these unhandled JSExceptions is that the CircuitHost dies and you loose your Blazor server session forcing the user to reload the page

from blazorise.

stsrki avatar stsrki commented on July 23, 2024

@David-Moreira Please try it for the coming 1.6 release. I would not change it too much in 1.5.

from blazorise.

David-Moreira avatar David-Moreira commented on July 23, 2024

I'd enable this by default and introduce a Blazorise option to be able to turn it off. I don't think a user will ever want to turn it off, but just in case... Agree?
Something like SafeJsInvoke //Whether to safely invoke internal javascript. Will ignore any exceptions that might be thrown as part of the javascript invoke process.

from blazorise.

stsrki avatar stsrki commented on July 23, 2024

Hmm. Can you explain how that will look in the code? Pseudo code is good.

from blazorise.

David-Moreira avatar David-Moreira commented on July 23, 2024

What do you mean?
It's an option, it either calls the current version or it calls the try catch all version.

if (safejsinvoke)
     InvokeSafe();
else
     InvokeWhateverWeHaveNow();

I'm not very familiar with the internals of our js invokes, so only when I start working will I see if there's any technical difficulty, but I don't expect any, it should be like that, the most centralized we can make it.

from blazorise.

stsrki avatar stsrki commented on July 23, 2024

Yes, but we already have InvokeSafeVoidAsync and InvokeSafeAsync, which should be safe already. That is why I'm confused about why we need an extra layer of "safe".

from blazorise.

David-Moreira avatar David-Moreira commented on July 23, 2024

Does this seem safe to you? hehe
image

from blazorise.

David-Moreira avatar David-Moreira commented on July 23, 2024

Whatever "safe" approach we have currently, is not safe in the manner that you can actually call it and trust that you won't have an exception.

from blazorise.

stsrki avatar stsrki commented on July 23, 2024

Does this seem safe to you? hehe image

Haha, absolutely not. Just have a quick prototype in a few places and create a draft PR so that we can see how it looks. Making it optional is also a good idea, as you said.

from blazorise.

David-Moreira avatar David-Moreira commented on July 23, 2024

Does this seem safe to you? hehe image

Haha, absolutely not. Just have a quick prototype in a few places and create a draft PR so that we can see how it looks. Making it optional is also a good idea, as you said.

Haha, yes.
Imagine you add a SafeReadFile(); and whenever you tried reading a file and it was locked or you had no permissions it threw an exception instead of like returning null? I don't think that would be expected behaviour of something "safe"?

Anyway, yes, I don't expect that there will be many places to change? But again, I'm not very familiar yet about those internals. I'd expect to only have to change in one or two places? Anyway, I'll provide a POC as suggested.

from blazorise.

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.