8000 Make module graph load order consistent by Pablete1234 · Pull Request #1108 · PGMDev/PGM · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Make module graph load order consistent #1108

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

Merged
merged 1 commit into from
Nov 28, 2022
Merged

Conversation

Pablete1234
Copy link
Member

Currently PGM has a ModuleGraph to resolve dependencies, however, every so often a required dependency is forgotten by a developer, and then what? What happens is because module load order is arbitrary (hash maps), it may work or not work at random, based on server restarts. What makes it worse, is that because "most" dependencies are right, they will force the "right" module to load first most of the times, making it extremely difficult to debug or find the one missing link in the chain.

Example: modules B, C, D, E, F, G all rely on module A being loaded first. However, module F has forgotten to declare that dependency (the developer making the module forgot to declare it). If, arbitrarily, any of the modules A, B, C, D, E, or G are loaded before F, then the error will be completely hidden away, as any of them will force A to load first, and so, by the time F loads, A will already be present. However, in the one-in-a-thousand time, that F loads before them all, all pgm maps using F will fail to load.

This is extremely frustrating behavior to debug, so what this change does is make it so the order is no longer arbitrary, but instead, is consistent with the order modules are defined/registered in pgm. This means if a bug occurs, it will occur every time, and if it doesn't occur, it won't ever occur.

Additionally, i've cleaned-up the raw usages of MapModule without generics, and made the module factories immutable.

Signed-off-by: Pablete1234 <pabloherrerapalacio@gmail.com>
@Pablete1234 Pablete1234 added the refactor Code needs to be redesigned label Nov 28, 2022
Copy link
Member
@Electroid Electroid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for cleaning this up

@Electroid Electroid merged commit 61c13f7 into dev Nov 28, 2022
@Electroid Electroid deleted the consistent-module-load-order branch November 28, 2022 18:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactor Code needs to be redesigned
Development

Successfully merging this pull request may close these issues.

2 participants
0