Skip to content

fix: skip onClientJoin cleanup while a prior drain is still running#99

Open
terbin wants to merge 1 commit into
Avanatiker:1.21.4from
terbin:fix/onclientjoin-skip-during-drain
Open

fix: skip onClientJoin cleanup while a prior drain is still running#99
terbin wants to merge 1 commit into
Avanatiker:1.21.4from
terbin:fix/onclientjoin-skip-during-drain

Conversation

@terbin
Copy link
Copy Markdown

@terbin terbin commented May 19, 2026

Reconnecting during the post-stop StorageFlow drain re-entered Events.onClientJoin which unconditionally ran StatisticManager.reset() and HotCache.clear(). The reset zeroed chunks/entities/players/containers mid-drain so EndFlow read all-zero counters and reported nothing_saved_yet, and the clear wiped HotCache.entities for chunks the IO coroutine had not yet processed, causing RegionBasedChunk.writeToStorage's null-branch to overwrite entity data for those chunks with an empty entities NBT.

Guard onClientJoin with if (capturing) return so an in-flight drain keeps its state. When autoDownload is enabled, emit a MessageManager sendInfo before the guard so users who opted into capture-on-join see why no capture started on the new server. autoDownload on the new server is forgone in this window; acceptable trade-off, the prior capture is finishing.

Verification

Drain survives reconnect to a different server without state wipe: EndFlow counters stay accurate and the captured region keeps its entity data instead of being overwritten with empty entity NBT.

Reconnecting during the post-stop StorageFlow drain re-entered Events.onClientJoin which unconditionally ran StatisticManager.reset() and HotCache.clear(). The reset zeroed chunks/entities/players/containers mid-drain so EndFlow read all-zero counters and reported nothing_saved_yet, and the clear wiped HotCache.entities for chunks the IO coroutine had not yet processed, causing RegionBasedChunk.writeToStorage's null-branch to overwrite entity data for those chunks with an empty entities NBT.

Guard onClientJoin with if (capturing) return so an in-flight drain keeps its state. When autoDownload is enabled, emit a MessageManager sendInfo before the guard so users who opted into capture-on-join see why no capture started on the new server. autoDownload on the new server is forgone in this window; acceptable trade-off, the prior capture is finishing.
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.

1 participant