I acknowledge that this is a niche issue. I’m using the Typescript runtime and for state management, I’m utilizing a class object (e.g., new Foo("")
). This class (Foo
) contains methods that help manage the state more cleanly. This approach works perfectly during runtime.
However, an error occurs in the console when attempting to retrieve the match state. It seems the endpoint responsible for this does not respect the toJSON
method of the Typescript class object. The desired behavior would be for the serialization process at this endpoint to ignore the function methods within the class object, by honoring its toJSON
method.
It’s important to note that the transport mechanism used for sockets correctly serialises the object and does not crash due to the presence of functions in the state object.
The specific line of code that seems related to this is: https://github.com/heroiclabs/nakama/blob/master/server/console_match.go#L116
This is the log line:
{"level":"error","ts":"2025-05-28T13:46:12.525Z","caller":"server/console_match.go:116","msg":"Error getting match state.","in":"id:\"86b2b378-8f8a-4156-ba0d-dadc2c3633ea.nakama\"","error":"json: unsupported type: func(goja.FunctionCall) goja.Value"}
Is it possible for this console endpoint to be updated to respect the toJSON
serialization of Typescript objects, similar to how the socket transport handles it?
- Versions: Nakama 3.26.0, {OS/Platform, e.g., Docker, Linux binary}, {client library (SDK) and version, if relevant}
- Server Framework Runtime language (If relevant) TS/JS