Skip to content

Commit 711b5e7

Browse files
Resolve issue where disconnect messages can get hidden when another packet is being sent (#906)
1 parent c5299c7 commit 711b5e7

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

protocol/src/main/java/org/geysermc/mcprotocollib/network/session/NetworkSession.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -209,16 +209,20 @@ private void doSendPacket(@NonNull Packet packet, @Nullable Runnable onSent) {
209209
if (!sendingEvent.isCancelled()) {
210210
final Packet toSend = sendingEvent.getPacket();
211211
this.channel.writeAndFlush(toSend).addListener((ChannelFutureListener) future -> {
212-
if (!future.isSuccess()) {
213-
return;
214-
}
215-
216212
if (onSent != null) {
217213
onSent.run();
218214
}
219215

220-
callPacketSent(toSend);
221-
}).addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE);
216+
// See PacketSendListener#thenRun - runnable first, success check later
217+
if (!future.isSuccess()) {
218+
// Mirrors Java client handling; uses a void promise when there's no runnable
219+
if (onSent != null) {
220+
channel.pipeline().fireExceptionCaught(future.cause());
221+
}
222+
} else {
223+
callPacketSent(toSend);
224+
}
225+
});
222226
}
223227
}
224228

0 commit comments

Comments
 (0)