Fabric API

Fabric API

108M Downloads

Networking API bug: sendPacket is not cancellable when using PacketSender.sendPacket with futures

filloax opened this issue ยท 3 comments

commented

Tried using the v1 API with custom packets, like this:

sender.sendPacket(FooPacket()) { after() }

using a sender obtained in, for example, ServerPlayConnectionEvents.JOIN, but this error happens:

org.spongepowered.asm.mixin.injection.callback.CancellationException: The call doSendPacket is not cancellable.
	at org.spongepowered.asm.mixin.injection.callback.CallbackInfo.cancel(CallbackInfo.java:101) ~[sponge-mixin-0.12.5+mixin.0.8.5.jar:0.12.5+mixin.0.8.5]
	at net.minecraft.network.Connection.handler$zdl000$fabric-networking-api-v1$sendInternal(Connection.java:614) ~[minecraft-common-project-root-1.20.1-loom.mappings.1_20_1.layered+hash.498914590-v2.jar:?]
	at net.minecraft.network.Connection.doSendPacket(Connection.java:220) ~[minecraft-common-project-root-1.20.1-loom.mappings.1_20_1.layered+hash.498914590-v2.jar:?]
	at net.minecraft.network.Connection.method_10761(Connection.java:212) ~[minecraft-common-project-root-1.20.1-loom.mappings.1_20_1.layered+hash.498914590-v2.jar:?]
	at io.netty.util.concurrent.AbstractEventExecutor.runTask(AbstractEventExecutor.java:174) ~[netty-common-4.1.82.Final.jar:?]
	at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:167) ~[netty-common-4.1.82.Final.jar:?]
	at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:470) ~[netty-common-4.1.82.Final.jar:?]
	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:569) ~[netty-transport-4.1.82.Final.jar:?]
	at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997) ~[netty-common-4.1.82.Final.jar:?]
	at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) ~[netty-common-4.1.82.Final.jar:?]

Cause seems to be a fabric API mixin missing a cancellable = true, in ClientConnectionMixin here:

private void sendInternal(Packet<?> packet, @Nullable PacketCallbacks listener, NetworkState packetState, NetworkState currentState, CallbackInfo ci, ChannelFuture channelFuture) {

commented

What Fabric API / Minecraft version are you experiencing this in?

commented

@modmuss50 I think this affects all versions after 1.19.1, when using sendPacket that accepts PacketCallbacks.

commented

1.20.1, with API 0.85.0