packetevents icon indicating copy to clipboard operation
packetevents copied to clipboard

PacketEvents 2.0 failed to inject randomly

Open ghost opened this issue 1 year ago • 28 comments

Describe the bug Randomly players while joining will get kicked with "PacketEvents 2.0 failed to inject"

Software brand Paper 1.20.4, paper 1.21 (this issue has been around a long time, since 2024-02-10 until present day)

Plugins Protocollib, vulcan, grim

How To Reproduce Randomly players will get disconnected when joining, its quite rare so hard to replicate, it has happened 191 times on my server out of ~150,000 player joins, here is a dump of all https://pastebin.com/GqBE0v0z

I assume this is because there is some kind of conflict/data race between protocollib, the shaded packet events in grim and the old shaded packet events in vulcan?

Expected behavior Shouldn't kick them

Additional context What causes this error? Is there some way to make packet events more fault tolerant rather than just kicking?, maybe some debug flag to println that I could enable and if it happens report back the debug data?

ghost avatar Nov 20 '24 23:11 ghost

Your having the same issue, eh? It's not rare for me though. It happens every time anyone tries to join.

LilPhyziX avatar Nov 21 '24 04:11 LilPhyziX

I am also getting this error every single time on 2.6.0 with Purpur 1.21.1.

FaultyFunctions avatar Nov 21 '24 16:11 FaultyFunctions

Actually updating Better Chat Bubbles to the latest version fixed this for me just now.

FaultyFunctions avatar Nov 21 '24 16:11 FaultyFunctions

@SergioK29 are there any other errors? do you have any other plugins installed? also see the comments above, they may solve your issue

booky10 avatar Nov 21 '24 21:11 booky10

@SergioK29 are there any other errors? do you have any other plugins installed? also see the comments above, they may solve your issue

there is actually one other plugin which touches netty besides plib, vulcan and grim, I have freedom chat but its on latest version so 🤷

ghost avatar Nov 26 '24 20:11 ghost

same error for me

Lory9098 avatar Dec 19 '24 14:12 Lory9098

this is happening for me as well, only packetevents causes this error. Server has ViaVersion and ViaBackwards (goes down as 1.19), runs on 1.20.4 latest purpur. It only kicks some players on join, and it even prevents them from joining the 2nd time sometimes. Is there any way we can find out what causes this?

kMagic142 avatar Mar 12 '25 21:03 kMagic142

private void onPlayerLogin( Connection connection, ServerPlayer player, CommonListenerCookie cookie, CallbackInfo ci ) { PacketEventsAPI<?> api = PacketEvents.getAPI();

    User user = api.getPlayerManager().getUser(player);
    if (user == null) {
        Object channelObj = api.getPlayerManager().getChannel(player);

        // Check if it's a fake connection
        if (!FakeChannelUtil.isFakeChannel(channelObj) &&
            (!api.isTerminated() || api.getSettings().isKickIfTerminated())) {
            // Kick the player if they're not a fake player
            player.connection.disconnect(Component.literal("PacketEvents 2.0 failed to inject"));
        }
        return;
    }

    api.getEventManager().callEvent(new UserLoginEvent(user, player));
} erm

BlueBVN06 avatar Mar 17 '25 21:03 BlueBVN06

+1

sh2kcs avatar Apr 16 '25 18:04 sh2kcs

Image plugin list

sh2kcs avatar Apr 16 '25 18:04 sh2kcs

Getting this randomly too, have to restart the server to fix it. 1.21.4 and 1.21.5, AxiomPaper, GrimAC, ViaVersion(Backwards/Rewind)

ShayBox avatar May 11 '25 22:05 ShayBox

Getting this randomly too, have to restart the server to fix it. 1.21.4 and 1.21.5, AxiomPaper, GrimAC, ViaVersion(Backwards/Rewind)

Most likely this is done by AxiomPaper or ProtocolLib

sh2kcs avatar May 12 '25 05:05 sh2kcs

How do you debug why PacketEvents failed to inject? there's no logs other than being kicked. Removing any of the plugins fixes the issue, but Axiom doesn't use Packet Events.

ShayBox avatar May 16 '25 07:05 ShayBox

Since I own a network of 1500 onlines and sell a well used plugin using PacketEvents I experienced this a lot too.

My suggestion is to completely ignore the phase of setting the Player object, it seems that both the bukkit events are not reliable enough and Player object is not truly needed to make PE work

I think we can:

  1. Keep current behavior but quietly ignore spigot event failures
  2. Retrieve the Player object on demand using Bukkit#getPlayer(UUID) maybe through a getter that assigns the returned instance if the stored one wasn't set previously
  3. both the things and we all are happy

ytnoos avatar May 16 '25 13:05 ytnoos

Experiencing the same problem. Very often on server switch, when doing /hub, PacketEvents kicks them saying it failed to inject. Bump

Fypsilon avatar May 30 '25 16:05 Fypsilon

Same issue.

BUMP

gbashmak avatar Jun 09 '25 11:06 gbashmak

Bump

Ayouuuu avatar Jun 12 '25 08:06 Ayouuuu

Same issue on 1.8.8. I am using PacketEvents for GrimAC.

linsaftw avatar Jun 13 '25 18:06 linsaftw

Why not allow the player but re-inject later?

linsaftw avatar Jun 14 '25 22:06 linsaftw

Bump

Krashe85 avatar Jun 16 '25 13:06 Krashe85

bump

rmilansky avatar Jun 16 '25 13:06 rmilansky

bump

TheQuiu avatar Jun 16 '25 14:06 TheQuiu

Bump

Since I own a network of 1500 onlines and sell a well used plugin using PacketEvents I experienced this a lot too.

My suggestion is to completely ignore the phase of setting the Player object, it seems that both the bukkit events are not reliable enough and Player object is not truly needed to make PE work

I think we can:

  1. Keep current behavior but quietly ignore spigot event failures
  2. Retrieve the Player object on demand using Bukkit#getPlayer(UUID) maybe through a getter that assigns the returned instance if the stored one wasn't set previously
  3. both the things and we all are happy

This is the best approach

linsaftw avatar Jun 18 '25 12:06 linsaftw

Why not allow the player but re-inject later?

We'll consider enabling this as an option. We could allow individuals to opt in for re-injection.

If the 'failed to inject' message is frequent, then there's an evident incompatibility between PacketEvents and another plugin. But if it occurs rarely, then it means that PacketEvents recognized a specific player has joined but failed to process any of their packets. Plugins that specifically try to process early packets may no longer function correctly with this option.

retrooper avatar Jun 18 '25 19:06 retrooper

In my case I had to switch to "GrimAC Lite" which is only available for Grim Lightning, the pre-release testing version of GrimAC, because Grim will always use it's bundled fork of PacketEvents even when one is installed on the server as a plugin, but lite does not include a bundled version and instead relies on the plugin.

If the injection happens when a player connects I don't see why trying to re-attempt to inject again after the player re-joins from being kicked the first time would cause any issues, maybe re-attempting on the same login without kicking would lead to issues, but as it stands it does not ever try to re-attempt until the server is restarted.

ShayBox avatar Jun 18 '25 20:06 ShayBox

If anyone here still experiences these problems, please try using https://github.com/retrooper/packetevents/actions/runs/15746891009?pr=1251

booky10 avatar Jun 19 '25 01:06 booky10

If anyone here still experiences these problems, please try using https://github.com/retrooper/packetevents/actions/runs/15746891009?pr=1251

Same issue!

[08:36:38 INFO]: LinsaFTW lost connection: PacketEvents 2.0 failed to inject

[08:36:40 INFO]: UUID of player LinsaFTW is 6e777127-0fa1-3452-a721-7318be135618
[08:36:40 INFO]: LinsaFTW[/127.0.0.1:54911] logged in with entity id 112766 at ([world]8.473296294805461, 71.0, 21.593743856890633)
[08:36:40 INFO]: **Deadd OWNER LinsaFTW joined the server

>version packetevents
[08:36:46 INFO]: packetevents version 2.9.0+92ae95f-SNAPSHOT

linsaftw avatar Jun 20 '25 11:06 linsaftw

I have the same issue where the player is getting kicked for "PacketEvents 2.0 failed to inject". This mostly happens when a player gets sent to the Lobby for me.

Kalibrier avatar Jun 24 '25 16:06 Kalibrier

If anyone here still experiences these problems, please try using https://github.com/retrooper/packetevents/actions/runs/15746891009?pr=1251

Same issue!

[08:36:38 INFO]: LinsaFTW lost connection: PacketEvents 2.0 failed to inject

[08:36:40 INFO]: UUID of player LinsaFTW is 6e777127-0fa1-3452-a721-7318be135618
[08:36:40 INFO]: LinsaFTW[/127.0.0.1:54911] logged in with entity id 112766 at ([world]8.473296294805461, 71.0, 21.593743856890633)
[08:36:40 INFO]: **Deadd OWNER LinsaFTW joined the server

>version packetevents
[08:36:46 INFO]: packetevents version 2.9.0+92ae95f-SNAPSHOT

which server version, which plugins, does this occur on every join or just occasionally?

booky10 avatar Jun 26 '25 01:06 booky10

If anyone here still experiences these problems, please try using https://github.com/retrooper/packetevents/actions/runs/15746891009?pr=1251

Same issue!

[08:36:38 INFO]: LinsaFTW lost connection: PacketEvents 2.0 failed to inject

[08:36:40 INFO]: UUID of player LinsaFTW is 6e777127-0fa1-3452-a721-7318be135618
[08:36:40 INFO]: LinsaFTW[/127.0.0.1:54911] logged in with entity id 112766 at ([world]8.473296294805461, 71.0, 21.593743856890633)
[08:36:40 INFO]: **Deadd OWNER LinsaFTW joined the server

>version packetevents
[08:36:46 INFO]: packetevents version 2.9.0+92ae95f-SNAPSHOT

which server version, which plugins, does this occur on every join or just occasionally?

for me, it happens on FlamePaper 1.8.8, and it just occurs occasionally

Kalibrier avatar Jun 28 '25 08:06 Kalibrier