TypeScript - friendsList not return userId

On the server if I run “friendsList” I expect a friends list to return.
yes, the list returns, the “username” parameter contains the expected information, but “state” is a series of strange characters, like a memory pointer, and “userId” is null.
I did not check the others, google-facebbok -… because for now I not use.

How to reproduce:

1 - add this code in to a RPG function, TypeScript, compile and run.
TypeScrip installation coming from pirate-panic-server, regarding the versions librery.

let friends1 = {} as nkruntime.FriendList;
try {
    let userId = ctx.userId;  // conain EX.'851280b2-e558-46e8-8bf5-337b1fcb935a'
    let limit = 100;
    let state = 0;
    friends1 = nk.friendsList(userId, limit, state);
} catch (error) {
    logger.error('   ERROR: %s   ', error.message);
}
friends1.friends?.forEach((f) => {
    // States are: friend(0), invite_sent(1), invite_received(2), blocked(3)
    logger.info('@@@@@ USERNAME @@@@@@: %s  ', f.user?.username);
    logger.info('@@@@@ STATE    @@@@: %d', f.state);
    logger.info('@@@@@ USER ID  @@@@@@: %s', f.user?.userId);
});

2 - create a user who has at least one friend
3 - call the RPG function from your favorite client, i use Unity
4 - check in the server log, look like this
5 - No Errors reported to client and in server logs

Expected Result

in the server log and back from the RPG in Unity at the end, but for semplicity we check the server log now.
@@@@@ USERNAME @@@@@@: ymtkncVZUU
@@@@@ STATE @@@@: 0
@@@@@ USER ID @@@@@@: 89afc542-2310-4c1b-b4fe-15ccfb8ee0e0

Actual Result

@@@@@ USERNAME @@@@@@: ymtkncVZUU
@@@@@ STATE @@@@: &{{{} 0} 0 0}
@@@@@ USER ID @@@@@@: %!s nil

Context - Environment

  • Client: Unity 3D ver. 202.3.9
  • Nakama: 3.3.0
  • Database: cockroach ver. 19.2.5 and cockroach ver. 20.2.10
  • Operating System and version: Ubuntu (old maybe 18) and windows 10, both with docker composer installation.
1 Like

@Ermes This looks like it might be a bug in how the JS runtime converts values from Go types into JavaScript objects and fields. Please open an issue and we’ll take a look :pray:

ok, opend the issue on github.

1 Like