Skip to content
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

Client issue when targeting blazor wasm #174

Open
ralinator opened this issue Dec 28, 2024 · 7 comments
Open

Client issue when targeting blazor wasm #174

ralinator opened this issue Dec 28, 2024 · 7 comments
Labels
Client Improvements or additions to the client code Good First Issue Good for newcomers
Milestone

Comments

@ralinator
Copy link

Describe the bug

Sorry wasn't sure if this should be a discussion point or an issue as support for blazor wasm isn't included in the supported platforms but I was thinking given that there is a bit of a drive from the MS side with these new templates to have blazor web apps and blazor hybrid apps sharing code etc. that it might be worth considering? Also to note once this one issue was fixed when I was running locally I was able to get the sync fully working with blazor wasm, there weren't any further blockers in order to get the sync or anything else on the client side working as far as I can tell.

The bug itself manifests when you want to pull/push to the server and it throws an error like below.
Image
If my understanding is correct this is where the exception actually gets thrown
https://source.dot.net/#System.Net.Http/System/Net/Http/[HttpClientHandler.cs](https://source.dot.net/#System.Net.Http/System/Net/Http/HttpClientHandler.cs,141),141
Then on the datasync repo it is trying to do this set in here https://github.com/CommunityToolkit/Datasync/blob/main/src/CommunityToolkit.Datasync.Client/Http/HttpClientExtensions.cs#L37

To Reproduce

Steps to reproduce the behavior:

I'm happy to create a minimal repro if required, just wanted to check first if doing the required fix for this project is even desired given it isn't a supported platform

  1. Create a solution using a blazor webassembly project as the client with sqlite set up (something similar to this https://github.com/[DavidH102/DotNet8-Blazor-WebAPP-with-SQLite-WASM](https://github.com/DavidH102/DotNet8-Blazor-WebAPP-with-SQLite-WASM), mine was a little different in a private personal project)
  2. Set up datasync using the standard documentation
  3. Try to pull/push from the server

Expected behavior

For the code that is looking to set automatic decompression to conditionally ignore this part of the code that throws the platformnotsupportedexception based on the platform. A fix that I have tested locally in the HttpClientFactory is the below -
Image

What platforms?

Note: Any bug or feature request that is opened for an unsupported environment will be automatically closed.

  • Server:

    • Version of dotnet being used to compile? dotnet 8
    • Library versions? 8.0.4
    • What database are you using? Cosmos DB
    • Where are you running the server? Locally in kestrel
    • GitHub repository containing the code (optional, but helps!) Is in a private repo but happy to create minimal repro
  • Client:

    • What platform (Android, iOS, Windows, etc.) versions are you running on? MS Edge on windows
    • Does it happen in an emulator / simulator, or only on a real device? N/A
    • Version of dotnet being used to compile? dotnet 8
    • .NET Runtime Environment (WPF, UWP, WinUI3, MAUI, etc.): Blazor WASM
    • Datsync Toolkit NuGet versions? 8.0.4
    • GitHub repository containing the code (optional, but helps!) Is in a private repo but happy to create minimal repro

Screenshots

If applicable, add screenshots to help explain your problem.

Additional context

@ralinator ralinator added Bug Requires Triage This issue has not been checked by the project team. labels Dec 28, 2024
@adrianhall
Copy link
Collaborator

Please create a minimal repro so we can write the appropriate validation logic and unit tests.

@adrianhall adrianhall added Good First Issue Good for newcomers Feature Request Client Improvements or additions to the client code and removed Bug Requires Triage This issue has not been checked by the project team. labels Jan 1, 2025
@adrianhall adrianhall added this to the 8.0.5 milestone Jan 1, 2025
@adrianhall
Copy link
Collaborator

… and, FWIW, I doubt this is the only Blazor WASM issue. We don’t test on Blazor WASM, so there may be further edge cases.

@ralinator
Copy link
Author

Think this should give you a minimal repro, only thing you might have to do before running is check the box in VS installer for ".NET 8.0 WebAssembly Build Tools". Other than that should be a case of running it and clicking the button on the home page.
https://github.com/ralinator/DataSyncWasmIssueRepro
Image

@ralinator
Copy link
Author

Not sure how much help I'll be but thought I would do a little playing around with this, as I somewhat expected doing tests in a bunit type test project didn't seem very helpful since it just seems to run on the operating system of the machine rather than in the browser context (windows for example).
Therefore it seems the only option if we want to try and get these edge cases where running in the browser does have different behaviour is to use some kind of end to end test runner. See example of a quick test using playwright against that minimal repro I did -
Image
From my limited knowledge of the project, the downsides I can think of implementing this are -

  • Adding a blazor wasm project to the tests as a starter, I guess the time consuming part of it would be thinking about how to cover those edge cases
  • Adding an end to end test runner, can be unreliable at times
  • Some work involved to integrate both of these into the CI pipeline and possibly some work to have a server backend running as well
  • Another couple of projects that need maintaining in the main solution

@adrianhall
Copy link
Collaborator

Agreed - my plan for this (since I have a number of other edge cases I want to test around Android, etc.) is to have a set of tests for each supported environment in their own test suite. These end-to-end tests would have a container for the server and a specific test runner for Android, Web, WPF, etc. that I can run.

Unfortunately, the project doesn't have that capability today and I have to learn how to do it. Fortunately for me, I sit in an organization with years of experience doing this - so hopefully I can get some assistance in setting it up. However, this is a long pole item. I'm not going to hold 8.0.5 for it.

@adrianhall
Copy link
Collaborator

Deferring to 9.0.0 to align with the plan for per-platform testing.

@adrianhall adrianhall modified the milestones: 8.0.5, 9.0.0 Jan 6, 2025
adrianhall added a commit to adrianhall/CommunityToolkit-Datasync that referenced this issue Jan 6, 2025
@adrianhall
Copy link
Collaborator

Have made the adjustment since it doesn't affect anything (low-risk) without adding required testing. Testing will come in 9.0.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Client Improvements or additions to the client code Good First Issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants