notificationsSend does nothing if persistent is false

When using nk.notificationsSend() to send in-game notifications (persistent=false), no clients receive any notifications over the socket.

If instead I use nk.notificationSend() in a loop to send the exact same notifications, then it works as expected.

Seems like a bug? This is with Nakama 3.25.0 in the TypeScript runtime.

export function sendGroupEndRaidNotification(ctx: nkruntime.Context, logger: nkruntime.Logger, nk: nkruntime.Nakama, groupId: string, raidId: string) {
    let groupUsers = {} as nkruntime.GroupUserList;
    try {
        groupUsers = nk.groupUsersList(groupId);
    } catch (error) {
        return;
    }
    if (!groupUsers.groupUsers || groupUsers.groupUsers.length == 0) {
        return;
    }

    let notification: nkruntime.NotificationRequest = {
        code: NotificationCode.EndRaid,
        subject: 'EndRaid',
        content: { gid: groupId, rid: raidId },
        persistent: false,
        userId: undefined
    };

    let notifications: nkruntime.NotificationRequest[] = [];
    for (let i = 0; i < groupUsers.groupUsers.length; i++) {
        let newNotification = notification;
        newNotification.userId = groupUsers.groupUsers[i].user.userId;
        notifications.push(newNotification);
        try {
            nk.notificationSend(notification.userId, 
                notification.subject, 
                notification.content, 
                notification.code, 
                notification.senderId, 
                notification.persistent); // <-- works (persistent: false)
        } catch (error) {
            logger.error("nk.notificationSend failed: error=%s", error.message);
        }
    }

    try {
        nk.notificationsSend(notifications); // <-- does not work (persistent: false)
    } catch (error) {
        logger.error("nk.notificationsSend failed: error=%s", error.message);
    }

    for (let i = 0; i < notifications.length; i++) {
        notifications[i].persistent = true;
    }
    try {
        nk.notificationsSend(notifications); // <-- works (persistent: true)
    } catch (error) {
        logger.error("nk.notificationsSend failed: error=%s", error.message);
    }
}

Hello @od-jg,

Are there no errors in the server logs?

I’d advise you to re-throw the error after it’s caught unless you’re trying to explicitly recover from it, otherwise the error may be masked and go unnoticed.