Bug in TypeScript before hook causing DeleteGroupAsync to fail

to simplify
if I understand with this code I create a group and destroy it

public async void OpenCloseGrop() {
** try {**
** IApiGroup group = await connection.Client.CreateGroupAsync(connection.Session, “GR”);**

** Debug.Log(group.Name);**
** Debug.Log(group.Id);**

** await connection.Client.DeleteGroupAsync(connection.Session, group.Id);**

** } catch (ApiResponseException e) {**
** Debug.LogError("Error: " + e.Message);**
** }**
}

but DeleteGroupAsync fails in both my project and Pirate panic example
what am I doing wrong
below are the logs

           #######################################

Pirate Panich
cockroach: v19.2.5 (Docker installatio)
nakama server: 3.1.0 (Docker installatio)
nakama unity client: [unreleased] after the 2.8.1 end befor 2.9.0
Unity: 2020.2.7

#### PiratePanich - Unity log #### 

Could not delete clan: TypeError: expects notification to be an object at github.com/heroiclabs/nakama/v3/server.(*runtimeJavascriptNakamaModule).notificationsSend.func1 (native)
UnityEngine.Debug:LogError (object)
PiratePanic.ClansMenuUI/d__26:MoveNext () (at Assets/PiratePanic/Scripts/Menus/ClansMenuUI.cs:211)
System.Runtime.CompilerServices.AsyncTaskMethodBuilder:SetException (System.Exception)
Nakama.Client/d__46:MoveNext ()
System.Runtime.CompilerServices.AsyncTaskMethodBuilder:SetException (System.Exception)
Nakama.ApiClient/d__48:MoveNext ()
System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1:SetException (System.Exception)
Nakama.HttpRequestAdapter/d__6:MoveNext ()
UnityEngine.UnitySynchronizationContext:ExecuteTasks ()

    #### Pirate Panich - Server log #### 

nakama | {“level”:“error”,“ts”:“2021-05-19T07:25:14.203Z”,“caller”:“server/runtime_javascript.go:437”,“msg”:“JavaScript runtime function raised an uncaught exception”,“mode”:“before”,“id”:"/nakama.api.nakama/deletegroup",“error”:“TypeError: expects notification to be an object at github.com/heroiclabs/nakama/v3/server.(*runtimeJavascriptNakamaModule).notificationsSend.func1 (native)”}
nakama | {“level”:“error”,“ts”:“2021-05-19T07:25:14.219Z”,“caller”:“server/runtime_javascript.go:319”,“msg”:“Runtime Before function caused an error.”,“id”:"/nakama.api.nakama/deletegroup"}

           #######################################

My Project
cockroach:v20.2.10 (Docker installatio)
nakama server:3.3.0 (Docker installatio)
nakama unity client: 2.9.0
Unity: 2020.2.7

    #### My Project - Unity log #### 

NullReferenceException: Object reference not set to an instance of an object
Nakama.UnityWebRequestAdapter+d__11.MoveNext () (at Library/PackageCache/com.heroiclabs.nakama-unity@affc960f25/Runtime/UnityWebRequestAdapter.cs:123)
UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) (at <42a5878ce129403083acccf18e43363f>:0)

    #### My Project - Server log #### 

nakama | {“level”:“error”,“ts”:“2021-05-19T10:04:35.744Z”,“caller”:“server/runtime_javascript.go:490”,“msg”:“JavaScript runtime function raised an uncaught exception”,“mode”:“before”,“id”:"/nakama.api.nakama/deletegroup",“error”:“TypeError: expects notification to be an object at github.com/heroiclabs/nakama/v3/server.(*runtimeJavascriptNakamaModule).notificationsSend.func1 (native)”}
nakama | {“level”:“error”,“ts”:“2021-05-19T10:04:35.748Z”,“caller”:“server/runtime_javascript.go:361”,“msg”:“Runtime Before function caused an error.”,“id”:"/nakama.api.nakama/deletegroup"}

1 Like

Hey @Ermes,

There was a bug in the TS before hook example, it has been fixed. The issue lies in this line.

I suspect you have the same issue in your own project, hope this helps.

2 Likes

yes, same problem, i solved it, thanksssssss

1 Like