Skip to content

Create GraphQLHttpWebSocket throw NotSupportedException in WASM #253

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

Closed
albiberto opened this issue Jun 21, 2020 · 3 comments
Closed

Create GraphQLHttpWebSocket throw NotSupportedException in WASM #253

albiberto opened this issue Jun 21, 2020 · 3 comments

Comments

@albiberto
Copy link

I tryed to use GraphQLClient in Blazor WASM project.
During client instating was throw an exception.
By reading the code I see this problem in System.Reactive.Concurrency.EventLoopScheduler.
The problem is the ThreadFactory in the library becouse it try to create a new thread.

This is the stack trace:

crit: Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100]
Unhandled exception rendering component: Cannot start threads on this runtime.
System.NotSupportedException: Cannot start threads on this runtime.
at (wrapper managed-to-native) System.Threading.Thread.Thread_internal(System.Threading.Thread,System.MulticastDelegate)
at System.Threading.Thread.StartInternal (System.Object principal, System.Threading.StackCrawlMark& stackMark) <0x31c6738 + 0x00008> in :0
at System.Threading.Thread.Start (System.Threading.StackCrawlMark& stackMark) <0x31c6630 + 0x0004c> in :0
at System.Threading.Thread.Start () <0x31c6570 + 0x0000e> in :0
at System.Reactive.Concurrency.EventLoopScheduler.EnsureThread () <0x31c5178 + 0x00036> in :0
at System.Reactive.Concurrency.EventLoopScheduler.Schedule[TState] (TState state, System.TimeSpan dueTime, System.Func3[T1,T2,TResult] action) <0x31bad40 + 0x0014e> in <filename unknown>:0 at System.Reactive.Concurrency.LocalScheduler.Schedule[TState] (TState state, System.Func3[T1,T2,TResult] action) <0x31b4ed8 + 0x0002e> in :0
at System.Reactive.Concurrency.Scheduler.Schedule (System.Reactive.Concurrency.IScheduler scheduler, System.Action action) <0x31b4c98 + 0x00060> in :0
at GraphQL.Client.Http.Websocket.GraphQLHttpWebSocket..ctor (System.Uri webSocketUri, GraphQL.Client.Http.GraphQLHttpClient client) <0x30b07d8 + 0x0013c> in :0
at GraphQL.Client.Http.GraphQLHttpClient..ctor (GraphQL.Client.Http.GraphQLHttpClientOptions options, GraphQL.Client.Abstractions.Websocket.IGraphQLWebsocketJsonSerializer serializer, System.Net.Http.HttpClient httpClient) <0x3062218 + 0x00140> in :0
at GraphQL.Client.Http.GraphQLHttpClient..ctor (GraphQL.Client.Http.GraphQLHttpClientOptions options, GraphQL.Client.Abstractions.Websocket.IGraphQLWebsocketJsonSerializer serializer) <0x3053fd8 + 0x0001e> in :0
at GraphQL.Client.Http.GraphQLHttpClient..ctor (System.Action`1[T] configure, GraphQL.Client.Abstractions.Websocket.IGraphQLWebsocketJsonSerializer serializer) <0x303e600 + 0x00010> in :0
at GraphQL.Client.Http.GraphQLHttpClient..ctor (System.Uri endPoint, GraphQL.Client.Abstractions.Websocket.IGraphQLWebsocketJsonSerializer serializer) <0x303e420 + 0x00030> in :0
at GraphQL.Client.Http.GraphQLHttpClient..ctor (System.String endPoint, GraphQL.Client.Abstractions.Websocket.IGraphQLWebsocketJsonSerializer serializer) <0x303e088 + 0x00012> in :0
at Angy.BackEndClient.Pages.IndexComponent.OnInitializedAsync () <0x3024408 + 0x00034> in :0
at Microsoft.AspNetCore.Components.ComponentBase.RunInitAndSetParametersAsync () <0x2f3ba28 + 0x00154> in :0

To solve the problem could it be a good idea change the EventLoopScheduler whit a custom implementation, since it is hosted in third-party library?

Thanks Alberto

@rose-a
Copy link
Collaborator

rose-a commented Jun 22, 2020

Are you planning to use subscriptions in your application?

If not, PR #252 will solve this for you.

If you need subscriptions, it's unfortunately not that easy, replacing the EventLoopScheduler with something else potentially has lots of unforeseen side effects...

But thanks for bringing the single-threaded nature of WASM to my attention...

@bjorg
Copy link
Contributor

bjorg commented Aug 15, 2020

Just ran into this issue as well.

@rose-a
Copy link
Collaborator

rose-a commented Sep 15, 2020

The EventLoopScheduler has been eliminated in v3.1.5, unsupported properties in v3.1.7.

I'm closing this in favour of #262

@rose-a rose-a closed this as completed Sep 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants