rbx-net icon indicating copy to clipboard operation
rbx-net copied to clipboard

Connecting a running game to a rojo server deletes events

Open xeqi opened this issue 1 year ago • 1 comments

Problem

When a game is running and calls Net.CreateDefinitions then Events are created under the net.out._NetManaged Instance

When starting a rojo server using a "$path" to load dependencies including rbx-net, the rojo server creates a DataModel with a net.out Instance without the events, as it only knows about what is on the filesystem.

If I attempt to connect a running game to that running rojo server using the rojo plugin, the plugin(?) will overwrite the runtime Instances currently in the game with the ones the server knows about. This removes the Events created by Net.CreateDefinitions.

Then event handlers in the game no longer work.

Workaround

When go into my dependency tree and add a file net/out/init.meta.json with contents

{"ignoreUnknownInstances": true}

the previous setup will keep the Events created by Net.CreateDefinitions, as rojo will ignore the _NetManaged Instance when updating. Then I can use the rewire library to hot reload code as desired.

Potential Fix

Adding this file to the repo might be a solution, but I have not given proper consideration to the ramifications of leaving old events around, and how such a choice could conflict with the intentional design decision mentioned in #78.

xeqi avatar Feb 20 '23 20:02 xeqi