Skip to content

fix: guard ViaVersion packet sends by connection state#134

Merged
vytskalt merged 2 commits into
vytskalt:mainfrom
Prime-Codes-GmbH:fix/viaversion-play-state
Jul 16, 2026
Merged

fix: guard ViaVersion packet sends by connection state#134
vytskalt merged 2 commits into
vytskalt:mainfrom
Prime-Codes-GmbH:fix/viaversion-play-state

Conversation

@mfnalex

@mfnalex mfnalex commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Prevents scoreboard packets from being written through ViaVersion when the player's connection is no longer ready to accept play packets.

This covers race conditions where a player disconnects, enters the configuration phase, or reconnects while a packet write is queued.

(For example when a player connects with the same UUID from another client, or when floodgate account linking is active and they connect with Bedrock while online with Java)

@mfnalex

mfnalex commented Jul 16, 2026

Copy link
Copy Markdown
Contributor Author

Example stacktrace of what this fixes: https://pastebin.com/ArSiLfef (connecting a player while simultaniously disconnecting the existing player through velocity + floodgate)

@vytskalt

Copy link
Copy Markdown
Owner

Should this check also be done when using the ViaAPI#sendRawPacket API in LegacyTeamDisplayPacketAdapter?

@mfnalex

mfnalex commented Jul 16, 2026

Copy link
Copy Markdown
Contributor Author

Should this check also be done when using the ViaAPI#sendRawPacket API in LegacyTeamDisplayPacketAdapter?

Good catch, tbh I haven't looked at anything besides the ModernPacketSender, because that was the only thing causing issues for us. I'll update the PR shortly.

@mfnalex

mfnalex commented Jul 16, 2026

Copy link
Copy Markdown
Contributor Author

I've refactored the checks into its own class and added it to the LegacyTeamDisplayPacketAdapter too now

@vytskalt
vytskalt merged commit 4022c09 into vytskalt:main Jul 16, 2026
@vytskalt

vytskalt commented Jul 16, 2026

Copy link
Copy Markdown
Owner

Thanks

You didn't need to be so paranoid about releasing the packet buffer, it's allocated on the heap and will be freed by GC

@mfnalex

mfnalex commented Jul 20, 2026

Copy link
Copy Markdown
Contributor Author

Thanks

You didn't need to be so paranoid about releasing the packet buffer, it's allocated on the heap and will be freed by GC

Better safe than sorry^^ thanks for merging!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants