Fabric API

Fabric API

108M Downloads

ClientPlayConnectionEvents executed on the Netty Thread

Lafolie opened this issue ยท 0 comments

commented

Hi, I just got finished up working on a mod called Shopper.

I used the ClientPlayConnectionEvents to trigger cache IO on JOIN and DISCONNECT events. During testing, I found the following prints using the typical modinit.LOG.* pattern:

[18:28:56] [Netty Local Client IO #0/ERROR] (shopper) Could not save cache /run/media/crocomire/fabric/shopper/run/config/shopper/shops./run/media/crocomire/fabric/shopper/run/saves/New World (1)/level.dat.json!
[18:28:56] [Netty Local Client IO #0/ERROR] (shopper) /run/media/crocomire/fabric/shopper/run/config/shopper/shops./run/media/crocomire/fabric/shopper/run/saves/New World (1)/level.dat.json (No such file or directory)

Please ignore the malformed paths, they were produced to trigger the error

I asked in discord and Tech has confirmed that it appears that code from these callbacks is executed on the Netty thread. Wrapping my calls in a client.execute lambda like you would for packet handlers resolved the issue, but this behaviour is not documented anywhere and Tech commented that it is a concern.

The code in question can be found here. The concerning behaviour is easily triggered by commenting out the execute wrapper and changing the string fname to an invalid file path, then loading a Minecraft world and quitting. The prints that generated the above output are on lines 212 and 213 of the same file.

No other mods are installed in the dev enironment, only stock Fabric, FAPI, and Shopper.