Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure that modules load in topological order on both client and server #1139

Open
philpax opened this issue Nov 5, 2023 · 0 comments
Open
Labels
enhancement New feature or request topic:api API functionality, including both host and guest

Comments

@philpax
Copy link
Contributor

philpax commented Nov 5, 2023

When a client joins a server, the clientside module entities are sent with client_bytecode_from_url, and these are then processed and loaded in an arbitrary order. This can lead to inconsistent/confusing behaviour, especially as the server creates the corresponding server entities (but does not wait) in topological order, which means the server has some likelihood of working and the client does not.

Ideally, both server and client would load their modules in topological order and guarantee that modules later in the order do not execute before their preceding modules have had a chance to complete their first tick. This is required to ensure that cross-module state sharing works as expected.

It may also be a good idea to define a known order for each level of the topological sort, so that the modules will always load in the same order (i.e. if A, B are depended upon by C, it will always load as A, B, C, and never B, A, C). The sort criteria might be a little confusing, though, especially as multiple packages can load the same dependency and might disagree on the ordering in use.

Open questions:

  1. How does this work with hotloading packages? Is there an issue here? My immediate feeling is "no" - loading a package at runtime will also load all of its dependents in the right order - but if multiple packages are hotloaded at the same time, we would want to ensure that they behave correctly.
  2. How much do we want to couple WASM modules with packages? In the future, I'd like to be able to spawn WASM modules that are decoupled from packages as workers or actors. What would the topological sort mean there? I think this would also be fine (runtime-spawned modules would be able to rely on their parent package having been loaded), but it may be possible to construct a failure case here.
@philpax philpax added enhancement New feature or request topic:api API functionality, including both host and guest labels Nov 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request topic:api API functionality, including both host and guest
Projects
None yet
Development

No branches or pull requests

1 participant