GithubHelp home page GithubHelp logo

Comments (14)

adamhearn avatar adamhearn commented on June 12, 2024 1

@chrissainty .NET 8 Blazor wasm only project (bumped from and was working with 6) with the same issue as described. The version of LocalStorage is the same (4.4.0). Browser is Edge latest on Windows 10.

The call it gets down to is:

BrowserStorageProvider::GetItemAsync
return await _jsRuntime.InvokeAsync<string>("localStorage.getItem", cancellationToken, key);

Nothing raised, nothing logged in VS or the browser console just hangs there seemingly forever.

from localstorage.

sponsorrockit avatar sponsorrockit commented on June 12, 2024

Browser details - no local storage error thrown just a disconnect from blazor server
Localstoragerror

from localstorage.

chrissainty avatar chrissainty commented on June 12, 2024

Hey @sponsorrockit, can you provide a minimal repro project, the package is working fine as far as a I can see testing on the sample projects and in a fresh project.

from localstorage.

sponsorrockit avatar sponsorrockit commented on June 12, 2024

from localstorage.

sponsorrockit avatar sponsorrockit commented on June 12, 2024

from localstorage.

chrissainty avatar chrissainty commented on June 12, 2024

Thanks for the detailed explanation @sponsorrockit.

Just to clarify, are you putting an object into local storage that contains 30+ other objects (your whole domain pretty much)? Just that you said you weren't happy sharing them here but anyone who uses your app will be able to get hold of them.

In terms of the issue you're seeing, it sounds like it might be a System.Text.Json problem. If you're saving one structure and then changing that structure and attempting to read it out again, it might need some extra configuration to handle that. It's not as forgiving as Newtonsoft JSON is. Have you tried adjusting the serialiser?

from localstorage.

julianadormon avatar julianadormon commented on June 12, 2024

I am having a similar issue trying
var StoredFormModels = await LocalStorage.GetItemAsync<List>("Forms");

I have not been able to narrow it down yet, however what is truly the bigger issue is that even though this is wrapped in a try/catch, it never reaches the catch.

It simply fails silently and causes the web socket to refresh. No errors in console or server.

from localstorage.

julianadormon avatar julianadormon commented on June 12, 2024

@chrissainty I'm not sure if you had a chance to review my comment above. Any ideas on how we can get this to fail properly?

`async void SaveFormLocally()
{
try
{
if (PageVm.FormPageVm == null) return;

        PageVm.FormPageVm.CustomFormSubmission.DateSubmitted = DateTime.UtcNow;

        PageVm.FormPageVm.CustomFormSubmission.CustomFormId = PageVm.FormPageVm.CustomForm.CustomFormId;
        
        var StoredFormModels = await LocalStorage.GetItemAsync<List<CustomFormSubmission>>("ProofpixForms");

        if (StoredFormModels != null)
        {
            if (StoredFormModels.Any(x => x.CustomForm.CustomFormId == PageVm.FormPageVm.CustomFormSubmission.CustomForm.CustomFormId))
            {
                var StoredCustomFormSubmission = StoredFormModels.FirstOrDefault(x => x.CustomForm.CustomFormId == PageVm.FormPageVm.CustomFormSubmission.CustomForm.CustomFormId);

                if (StoredCustomFormSubmission != null)
                {
                    StoredFormModels.Remove(StoredCustomFormSubmission);
                }

                StoredFormModels.Add(PageVm.FormPageVm.CustomFormSubmission);
            }
            else
            {
                StoredFormModels.Add(PageVm.FormPageVm.CustomFormSubmission);
            }
        }
        else
        {
            StoredFormModels = new List<CustomFormSubmission> { PageVm.FormPageVm.CustomFormSubmission };
        }

        await LocalStorage.SetItemAsync("ProofpixForms", StoredFormModels);
    }
    catch (Exception Ex)
    {
        Console.WriteLine(Ex.ToString());
    }
}`

from localstorage.

adamhearn avatar adamhearn commented on June 12, 2024

Also, swapped out this library for another and it exhibited the exact same issue. If it wasn't already obvious it's safe to say that it's a .NET 8 wasm issue rather than an issue with this library.

from localstorage.

julianadormon avatar julianadormon commented on June 12, 2024

I'm using Blazer Server .net 7 with System.Text.Json.
I ended up saving my data as strings and then serialize those to avoid the issue. Seems to be working so far.

from localstorage.

julianadormon avatar julianadormon commented on June 12, 2024

Actually, I take that back. I am getting a socket reset with no error now calling:
var StoredFormStrings = await LocalStorage.GetItemAsync<List>("ProofpixForms");

from localstorage.

panoukos41 avatar panoukos41 commented on June 12, 2024

After coming across this issue and having the same problem myself in Blazor Server .NET 6.0 & lib version 4.3.0 I get no exception and the connection just resets.

It must have something to do with the object size. Although the object ends up in the storage the connection just crushes. When I reduced the size of my object it worked fine. It didn't matter if I used the AsString or serialized it to a string myself.

from localstorage.

chrissainty avatar chrissainty commented on June 12, 2024

For Blazor Server, some people could be hitting the default limit of the SignalR connection. It's worth trying to up that and see if that cures the issues.

from localstorage.

panoukos41 avatar panoukos41 commented on June 12, 2024

@chrissainty yes for server increasing the limit fixed the problem thanks.

from localstorage.

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.