lavalink-devs/lavalink-client

Registered node events will stop sending after a while (4h+)

WeeeeeeeeeeS opened this issue · 3 comments

Edit by maintainer: Listeners stop getting events when they encounter uncaught exceptions.


I am having a weird issue.
so when i run my bot this will work fine:

            node.on(TrackEndEvent.class).subscribe(NodeEventsHandler::trackEndEvent);

but after 5h+ it will stop sending TrackEventEvent

it leads to these methods:

    @NonNull
    public void trackEndEvent(TrackEndEvent event) {
        var endReason = event.getEndReason();
        endedEvent(endReason.getMayStartNext(), event.getTrack());
        System.out.println(bot.getGuild() +" -> Track End: " + endReason.name());
    }


    public void endedEvent(boolean mayStartNext, Track endedTrack) {
        if (mayStartNext) {
            if (isLooping && endedTrack != null) {
                getLink().createOrUpdatePlayer()
                        .setEncodedTrack(endedTrack.getEncoded())
                        .setPosition(0L)
                        .subscribe();
                return;
            }
            if (isQueueLooping && endedTrack != null) {
                addToQueue(endedTrack, null);
                return;
            }
            nextTrack(null, null);
        }
        if (isAutoPlay && queue.isEmpty()) {
            autoPlay(endedTrack);
            return;
        }
    }

Node (Skipped/Replaced):

2024-01-21T16:08:17.280Z  INFO 178040 --- [  XNIO-1 task-2] l.server.io.RequestLoggingFilter         : PATCH /v4/sessions/okb2z23zukd0jjj8/players/1179002246478954516?noReplace=false, client=//, payload={"track":{"encoded":"QAABywMAF1dvcmxkJ3MgU21hbGxlc3QgVmlvbGluAANBSlIAAAAAAALCCgAWNjhFa2hWV0llVUxoSHhjYmkxUWh6SwABADVodHRwczovL29wZW4uc3BvdGlmeS5jb20vdHJhY2svNjhFa2hWV0llVUxoSHhjYmkxUWh6SwEAQGh0dHBzOi8vaS5zY2RuLmNvL2ltYWdlL2FiNjc2MTZkMDAwMGIyNzMwZjBlNzkwMGExMDJhYWE3MGVkMzBkM2UBAAxRTVJTWjIwMDMzMjQAB3Nwb3RpZnkBAAxPSyBPUkNIRVNUUkEBADVodHRwczovL29wZW4uc3BvdGlmeS5jb20vYWxidW0vN3JiZGdZS3oxREk0Z1hNV3ZlcVM1VAEANmh0dHBzOi8vb3Blbi5zcG90aWZ5LmNvbS9hcnRpc3QvNnMyMnQ1WTNwclFIeWFIV1VOMVIxQwABAGtodHRwczovL3Auc2Nkbi5jby9tcDMtcHJldmlldy8xYWU1MWI5ZTBhNDVlYzAyYzFlMzMwYmRhZDE4ODIxNzdmNDI4NThhP2NpZD1lNzFhZTk2YzMwZTU0ZmQ1OWI3MGIxNzgzMWVhYmY1NwAAAAAAAAAAAA=="}}

and the client got 0 events 💀

=========

and here i restarted the bot, and it started receiving the events once again

Requested debug logs in discord.

I also met this problem before. I even subscribe on LavalinkClient, and the object never got dump before
image

Edit: Only some time + without any sequence, but I suspected it is my own problem

Event listeners are cancelled when an exception inside of them are not caught by the end user.
This behaviour seems to be undocumented from what I could tell, so I made sure to document it on the methods in the client.