-
Notifications
You must be signed in to change notification settings - Fork 751
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
Observable.Delay throws PlatformNotSupportedException on Blazor WASM. #2061
Comments
The issue is slightly deeper than this. IScheduler sch = DefaultScheduler.Instance.DisableOptimizations();
await Observable.Return(1)
.Delay(TimeSpan.FromSeconds(1), sch)
.ToTask(); You should then see So the question is why does it fail when used in the default way? The basic problem here is this: by default all timed operators in Rx default to using The problem of course is that you're not allowed to create new threads on WASM. The workaround above basically downgrades the scheduler to one where no optional features (such as long running operation support) are available. This is probably overkill. This may be disabling other optimizations that would actually work. It might be that the most straightforward way for us to fix this is to have the public bool SupportsLongRunning => true; but if this were to return There was a time where different builds of Rx for different environments would hard-code The problem for WASM is that it's not a distinct build target. Because of the "One .NET" initiative, it just ends up being Presumably there's some way to discover at runtime that thread creation is unavailable—other libraries must have encountered this problem on WASM before. So it might just be a case of finding out what the preferred way is to ask "Are we allowed to create new threads?" and making However, there might well be other WASM-specific problems. The root cause of why it was possible for this to blow up like this is that we've never executed our test suites on WASM. So rather than merely fixing up this one symptom, I think the best thing to do would be to work out how to run the full Rx test suite on Blazor WASM. That would reveal any other issues. |
Note to self: maybe https://devblogs.microsoft.com/dotnet/introducing-ms-test-runner/ could help with this? |
The other suggestion is to use https://learn.microsoft.com/en-us/aspnet/core/client-side/dotnet-interop?view=aspnetcore-8.0 as a testing approach. |
Bug
On Blazor WASM,
Observable.Delay
is not implemented.Index.razor
Exception:
The text was updated successfully, but these errors were encountered: