Skip to content

AttachmentSyncException disconnects client when target entity is not yet loaded #5196

@pandasonic-collective

Description

@pandasonic-collective

Fabric API Version: 0.138.4+1.21.10 (fabric-data-attachment-api-v1 1.8.33)
Minecraft Version: 1.21.10
Fabric Loader Version: 0.18.4

Logs:
2026-02-08-6.log

Description:
When a mod registers a synced attachment (e.g. prometheus:fire_type), Fabric API's attachment sync system can disconnect the client from the server with an AttachmentSyncException: Received attachment change for unknown target! if the target entity is not currently loaded on the client.
This happens because AttachmentChange.tryApply() (line ~165) throws AttachmentSyncException when targetInfo.getTarget(world) returns null, and AttachmentSyncClient catches this exception and explicitly calls disconnect().

An entity may not be loaded on the client for legitimate reasons:
Race condition between entity tracking and attachment sync packets
Entity is in a chunk that was just unloaded
Server sends attachment data slightly before the entity spawn packet arrives

Steps to Reproduce:
Install any mod that registers a synced entity attachment (e.g. Prometheus with fire_type)
Play on a server with multiple players/many entities
Observe periodic client disconnects with the error: Received attachment change for unknown target! Attachment identifier: prometheus:fire_type

Expected Behavior:
The client should log a warning and skip the attachment update for the missing target, similar to how vanilla Minecraft handles ClientboundSetEntityDataPacket for untracked entities.

Actual Behavior:
The client disconnects from the server.

Relevant Code:
In AttachmentChange.java:
public void tryApply(World world) throws AttachmentSyncException { AttachmentTarget target = targetInfo.getTarget(world); Object value = decodeValue(world.getRegistryManager()); if (target == null) { // ... builds error text ... throw new AttachmentSyncException(errorMessageText); } target.setAttached((AttachmentType<Object>) type, value);}

In AttachmentSyncClient.java:
try { attachmentChange.tryApply(context.client().world);} catch (AttachmentSyncException e) { AttachmentEntrypoint.LOGGER.error("Error accepting attachment changes", e); context.responseSender().disconnect(e.getText()); // <-- disconnects the client! break;}

Suggested Fix:
When target == null in tryApply, log a warning and return early instead of throwing. This mirrors vanilla behavior where packets for unknown entities are silently dropped.

Temp Patch:
I have created temp patch mod that so far seems to take care of the issue and has made things like Flashback mod failure and Server disconnections from happening: https://github.com/pandasonic-collective/AttachmentSyncFix

Metadata

Metadata

Assignees

No one assigned

    Labels

    backportbugSomething isn't working

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions