streamUserJoin method throws a type error

Hi everyone!

Today I updated from nakama 3.5 to nakama 3.12 and encountered the following error message:

{"level":"error","ts":"2022-06-04T16:00:00.799Z","caller":"server/runtime_javascript.go:517","msg":"JavaScript runtime function raised an uncaught exception","mode":"rpc","id":"initsession","error":"TypeError: expects string at github.com/heroiclabs/nakama/v3/server.(*runtimeJavascriptNakamaModule).streamUserJoin.func1 (native)"}

The typescript code I have looks like this and should be pretty straight forward:

nk.streamUserJoin(
        ctx.userId,
        ctx.sessionId,
        {
            mode: StreamMode.Data,
        },
        true,
        false
    );

    nk.streamUserJoin(
        ctx.userId,
        ctx.sessionId,
        {
            mode: StreamMode.ChatChannel,
            label: "global",
        },
        true,
        false
    );

    nk.streamUserJoin(
        ctx.userId,
        ctx.sessionId,
        {
            mode: StreamMode.ChatChannel,
            label: "marketplace",
        },
        true,
        false
    );

The code is executed in an rpc function and should register the user for all streams that are relevant.

And before the update to 3.12.0 it has worked fine as far as I’m aware :slight_smile:

Any help is appreciated :pray:

You’re missing a parameter added sometime in between 3.5.0 and 3.12.0. Some code working in one version and not a newer one is always worth a trip to the docs first - Nakama: Function Reference | Heroic Labs Documentation

Seems like all the parameters are now required :slight_smile:
So I’m missing the status field :sweat_smile:

The typescript function still lists the parameters as optional though:

So it would be cool if those could be updated :slight_smile:
Also the order of the arguments was changed? That would be even more urgent to fix :sweat_smile:
As with the order in the document I would get ts errors.

Thank you for your help! :pray:

Just noticed that the order in the table is changed, but not in the example code. Very confusing :thinking:

Thanks @MWFIAE, will get the docs updated right away :+1:

1 Like

Thank you! :pray:

After playing around a bit more I also noticed that the required arguments aren’t required at all and that my error actually comes from the fact that my setup in unity no longer works after the update.
(I’m calling the rpc before the socket realizes it’s been connected and therefore I’m sending the rpc without user and session id. )