Code Monkey home page Code Monkey logo

Comments (11)

chrissainty avatar chrissainty commented on July 24, 2024 2

Ok, so it looks like the changes made to fix #57 and subsequent bug fixes have broken things for others.

I would suggest @soltrac and @daniel-rck go back to an earlier version of the library and I'll have a think about what to do.

from localstorage.

chrissainty avatar chrissainty commented on July 24, 2024 1

@daniel-rck @soltrac The issues should be resolved in the latest release. Let me know if you experience any further issues.

from localstorage.

chrissainty avatar chrissainty commented on July 24, 2024

Hi @daniel-rck, are you sure it broke with v2.1.4? There were no changes to the SetItem<T> method only to the GetItem<T> method. However, v2.1.3 had changes to the SetItem<T> method.

from localstorage.

daniel-rck avatar daniel-rck commented on July 24, 2024

On my side there were also no changes besides the LocalStorage-Nuget.
I tested other string, they were working. In fact only my tyical JWT failed. Can I send you the value that you can reproduce the error? I feel unsafe posting it here.

from localstorage.

chrissainty avatar chrissainty commented on July 24, 2024

Yes, please do. Either DM me it on Twitter or there is a contact form on my website via the Speaking page.

from localstorage.

chrissainty avatar chrissainty commented on July 24, 2024

@daniel-rck I've used your JWT in the sample app and it has saved to local storage fine, without any errors.

from localstorage.

soltrac avatar soltrac commented on July 24, 2024

I have exactly the same problem.

For example this, in new version this is not working for me. It was working ok on previous version.

.SetAsync("Blablabla", "6QLE0LL7iw7tHPAwold31qUENt3lVTUZxDGqeXQFx38=");

crit: Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100] blazor.webassembly.js:1:36074 Unhandled exception rendering component: 'Q' is an invalid end of a number. Expected a delimiter. Path: $ | LineNumber: 0 | BytePositionInLine: 1. blazor.webassembly.js:1:36074 System.Text.Json.JsonException: 'Q' is an invalid end of a number. Expected a delimiter. Path: $ | LineNumber: 0 | BytePositionInLine: 1. ---> System.Text.Json.JsonReaderException: 'Q' is an invalid end of a number. Expected a delimiter. LineNumber: 0 | BytePositionInLine: 1. blazor.webassembly.js:1:36074 at System.Text.Json.ThrowHelper.ThrowJsonReaderException (System.Text.Json.Utf8JsonReader& json, System.Text.Json.ExceptionResource resource, System.Byte nextByte, System.ReadOnlySpan1[T] bytes) <0x2ab0460 + 0x00020> in :0 blazor.webassembly.js:1:36074
at System.Text.Json.Utf8JsonReader.TryGetNumber (System.ReadOnlySpan1[T] data, System.Int32& consumed) <0x2a154a0 + 0x00136> in <filename unknown>:0 blazor.webassembly.js:1:36074 at System.Text.Json.Utf8JsonReader.ReadFirstToken (System.Byte first) <0x28771f0 + 0x00160> in <filename unknown>:0 blazor.webassembly.js:1:36074 at System.Text.Json.Utf8JsonReader.ReadSingleSegment () <0x2876bb8 + 0x001fe> in <filename unknown>:0 blazor.webassembly.js:1:36074 at System.Text.Json.Utf8JsonReader.Read () <0x2876740 + 0x0000e> in <filename unknown>:0 blazor.webassembly.js:1:36074 at System.Text.Json.JsonSerializer.ReadCore (System.Text.Json.JsonSerializerOptions options, System.Text.Json.Utf8JsonReader& reader, System.Text.Json.ReadStack& readStack) <0x28760b0 + 0x0005e> in <filename unknown>:0 blazor.webassembly.js:1:36074 --- End of inner exception stack trace --- blazor.webassembly.js:1:36074 at System.Text.Json.ThrowHelper.ReThrowWithPath (System.Text.Json.ReadStack& readStack, System.Text.Json.JsonReaderException ex) <0x2b02e80 + 0x00108> in <filename unknown>:0 blazor.webassembly.js:1:36074 at System.Text.Json.JsonSerializer.ReadCore (System.Text.Json.JsonSerializerOptions options, System.Text.Json.Utf8JsonReader& reader, System.Text.Json.ReadStack& readStack) <0x28760b0 + 0x00292> in <filename unknown>:0 blazor.webassembly.js:1:36074 at System.Text.Json.JsonSerializer.ReadCore (System.Type returnType, System.Text.Json.JsonSerializerOptions options, System.Text.Json.Utf8JsonReader& reader) <0x286d0f8 + 0x0002e> in <filename unknown>:0 blazor.webassembly.js:1:36074 at System.Text.Json.JsonSerializer.Deserialize (System.String json, System.Type returnType, System.Text.Json.JsonSerializerOptions options) <0x286c090 + 0x0017a> in <filename unknown>:0 blazor.webassembly.js:1:36074 at System.Text.Json.JsonSerializer.Deserialize[TValue] (System.String json, System.Text.Json.JsonSerializerOptions options) <0x2a87938 + 0x0000c> in <filename unknown>:0 blazor.webassembly.js:1:36074 at Blazored.LocalStorage.LocalStorageService.GetItemAsync[T] (System.String key) <0x2aaf650 + 0x0018e> in <filename unknown>:0 blazor.webassembly.js:1:36074 at Blazored.LocalStorage.LocalStorageService.RaiseOnChangingAsync (System.String key, System.Object data) <0x2ab7bd0 + 0x000fc> in <filename unknown>:0 blazor.webassembly.js:1:36074 at Blazored.LocalStorage.LocalStorageService.SetItemAsync (System.String key, System.Object data) <0x2ab6bb8 + 0x000fe> in <filename unknown>:0

from localstorage.

soltrac avatar soltrac commented on July 24, 2024

What i see is that setitemasync is believing that i'm trying to save an int, instead a string.

from localstorage.

daniel-rck avatar daniel-rck commented on July 24, 2024

The problem comes from LocalStorageService.cs, Line 183, when RaiseOnChangingAsync calls GetItemAsync<object>(key). Should it be the same T and also GetItemAsync<string>(key) so it's running in the else-clause?

EDIT: I thought about it, maybe a simple try-catch would be enough, when the T of GetItemAsync is object?

from localstorage.

chrissainty avatar chrissainty commented on July 24, 2024

The problem is that when RaiseOnChangingAsync is called we don't know what T should be. A developer could be overwriting a value with a certain type, and replacing it with a value of a different type.

I've added a new internal version of GetItemAsync which doesn't have the additional check for T not being a string. This seems to have fixed it.

from localstorage.

daniel-rck avatar daniel-rck commented on July 24, 2024

Yep, removing this condition works for me too. The checks for JSON start and end should be enough imho.

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.