Skip to content

Failed to start Websocket client , error: 'Operation is not supported on this platform.' #48

Open
@MoienTajik

Description

@MoienTajik

Bug report

Describe the bug

I am using Supabase v1.1.1 in a Blazor WebAssembly (WASM) application running on .NET 8. The issue occurs with this commit in the Supabase.Realtime package, so v1.1.0 is working without any issue. Specifically, the problem is on this line, where the following method is invoked:

socket.Options.SetRequestHeader(header.Key, header.Value);

This method is marked with [UnsupportedOSPlatform("browser")], and when calling InitializeAsync in a Blazor WASM application, the following exception is thrown:

Error: One or more errors occurred. (Failed to start Websocket client , error: 'Operation is not supported on this platform.')

To Reproduce

  1. Create a new Blazor WASM project.
  2. Install the Supabase NuGet package v1.1.1.
  3. Register Supabase in DI Container (or manually create an instance of it) as shown below:
builder.Services.AddSingleton(sp =>
    {
        var client = new SupabaseClient(
            Constants.Supabase.Url,
            Constants.Supabase.ApiKey,
            new()
            {
                AutoRefreshToken = true,
                AutoConnectRealtime = true,
                SessionHandler = sp.GetRequiredService<SupabaseSessionProvider>()
            });

        return client;
    }
);

Call InitializeAsync on the Supabase client:

await supabase.InitializeAsync();

Expected behavior

The InitializeAsync method should not throw an exception, or there should be a guard like [UnsupportedOSPlatform("browser")] to prevent setting AutoConnectRealtime to true on the WASM runtime.

System information

  • OS: macOS
  • Browser: Arc (Chromium)
  • Supabase NuGet Package Version: 1.1.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions