heroiclabs / nakama-unity

Unity client for Nakama server.
https://heroiclabs.com/docs/unity-client-guide
Other
407 stars 75 forks source link

Unity - [WebGL] SOCKET_REF_MAP.has is not a function #138

Closed supernimbus-daithi closed 1 year ago

supernimbus-daithi commented 1 year ago

Unity version: 2019.3.15f1

Nakama SDK version: v3.4.1

On WebGL platform, calling socket.CloseAsync() after invalid credentials auth results in a Web Player crash.

Example code:

{
        try
        {
            _session = await _client.AuthenticateEmailAsync("test@email.net", "password");
        }
        catch (ApiResponseException ex)
        {
            Debug.LogError(ex.Message);
        }
        catch (Exception ex)
        {
            Debug.LogError(ex.Message);
        } 

        await _socket.CloseAsync();
}

Stack trace example:

UnityLoader.js:4 exception thrown: TypeError: SOCKET_REF_MAP.has is not a function, 
TypeError: SOCKET_REF_MAP.has is not a function
    at _NKCloseSocket (blob:http://127.0.0.1:8887/f135b843-a35c-4058-a023-ec1dbad5f828:8:59792)

image

lugehorsam commented 1 year ago

Hey @supernimbus-daithi we've submitted a PR to fix this. Please note that you also need to connect the socket before closing it.

lugehorsam commented 1 year ago

@supernimbus-daithi we've resolved this issue and it will be included in the next release. If you would like to include the fix in your project now you can point your .upm file to master.