[GH-ISSUE #5249] Native mods: messages sent from native_server_stopping never reach players #1610

Closed
opened 2026-11-02 15:48:21 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @arismoko on GitHub (Oct 31, 2026).
Original GitHub issue: https://github.com/horizon-rust/horizon/issues/5249

Originally assigned to: @arismoko on GitHub.

🤖 Filed by Aria's agent swarm, Dyna, not by Aria.

#5140 merged at 46a0cf3ee with the point from its review still open: a mod message sent from native_server_stopping never reaches the players.

What happens: the hook's doc comment says a mod can "save its own data or tell them" here, and native_net_send_to_player returns Ok. But that call only queues the message in native_net.to_players. The queue is sent by flush_native_net, and the only call to it is in lan.rs (around line 1966), at the end of a normal tick. Neither stop path calls it after the hook:

  • integrated.rs (around line 678): the hook runs, then the guests are saved and disconnected.
  • dedicated.rs stop_dedicated (around line 1683): the hook runs, then the players are saved and disconnected.

So the message is dropped when the players are disconnected.

To reproduce: a native mod whose native_server_stopping calls native_net_send_to_player for each player, with a client-side mod that logs what arrives. Stop a dedicated server (or close a LAN world with a guest): nothing arrives.

Fix direction: in both stop paths, call flush_native_net once after native_server_stopping and before the players are disconnected, while the LAN host is still in place.

Part of #4953. The recommended end-to-end test mod, horizon-machine-sample, was not used to find this; it was found by reading the code during review. A fix PR will include an in-game check.

Originally created by @arismoko on GitHub (Oct 31, 2026). Original GitHub issue: https://github.com/horizon-rust/horizon/issues/5249 Originally assigned to: @arismoko on GitHub. > 🤖 Filed by Aria's agent swarm, Dyna, not by Aria. #5140 merged at `46a0cf3ee` with the point from its review still open: a mod message sent from `native_server_stopping` never reaches the players. **What happens:** the hook's doc comment says a mod can "save its own data or tell them" here, and `native_net_send_to_player` returns `Ok`. But that call only queues the message in `native_net.to_players`. The queue is sent by `flush_native_net`, and the only call to it is in `lan.rs` (around line 1966), at the end of a normal tick. Neither stop path calls it after the hook: - `integrated.rs` (around line 678): the hook runs, then the guests are saved and disconnected. - `dedicated.rs` `stop_dedicated` (around line 1683): the hook runs, then the players are saved and disconnected. So the message is dropped when the players are disconnected. **To reproduce:** a native mod whose `native_server_stopping` calls `native_net_send_to_player` for each player, with a client-side mod that logs what arrives. Stop a dedicated server (or close a LAN world with a guest): nothing arrives. **Fix direction:** in both stop paths, call `flush_native_net` once after `native_server_stopping` and before the players are disconnected, while the LAN host is still in place. Part of #4953. The recommended end-to-end test mod, [horizon-machine-sample](https://github.com/arismoko/horizon-machine-sample), was not used to find this; it was found by reading the code during review. A fix PR will include an in-game check.
Author
Owner

@arismoko commented on GitHub (Oct 31, 2026):

🤖 Agent: /claim

<!-- gh-comment-id:6545982759 --> @arismoko commented on GitHub (Oct 31, 2026): 🤖 Agent: /claim
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
horizon-rust/horizon#1610
No description provided.