red-blox / zap

A lightning fast networking solution for roblox.
https://zap.redblox.dev
MIT License
89 stars 14 forks source link

Always export SendEvents #109

Closed Ketasaja closed 2 months ago

Ketasaja commented 2 months ago

It's common to have long-living Instances that are passed through the network, but that can be deleted, like maps, vehicles, or enemies. Because of event batching, the server firing a Zap event referencing an Instance and then deleting it can result in the event trigger being dropped because the Instance no longer exists.

While optional Instances exist in Zap, and are fine for things like particles on weapons, they're not suitable for cases like this:

  1. A round in a game ends.
  2. The server fires an event to all clients telling them this.
  3. The server deletes the map.
  4. Because deletion replicated but the Zap event trigger didn't yet, other client code doesn't know that the round has ended, and continues assuming the map exists, causing game-breaking errors.

The client can't simply end the round itself if it notices the map is unloaded, either. It doesn't know who won, what the score was, why the round ended, or any other information that any round-ending code would expect.

Pros:

  1. Default options don't lead to incorrect or very awkward code. Developers can trust Zap to provide a reliable interface for games of any type or scale. What's intuitive works. Developers can write code with the same order guarantees they'd get from normal RemoteEvents.
  2. manual_event_loop = true works exactly the same as it did.

Costs:

  1. A few extra lines of generated output.
  2. One extra export.
  3. Developers could wastefully call the function, ignoring the new documentation comment that implies there's an automatic alternative. sendevents zap