Closed guybedford closed 10 years ago
This may well be related to https://github.com/jorendorff/js-loaders/issues/80
Note that this change does break the first assertion of updateLinkSetOnLoad
because after {loads/a loads/b}
is linked, loads/b
is removed from the {loads/c loads/a loads/b}
linkset, so that when the next updateLinkSetOnLoad is called on that linkset, loads/b
isn't in it anymore failing the assertion.
I'm not sure what the intention is here. For now, this is working on my test cases, and is the simplest fix I can see, so I'm silencing the assertion in es6-module-loader. More information would be really appreciated in due course.
I can confirm this change does resolve #80.
To confirm, the proposed solution here does work out in complex deep shared dependency scenarios.
This issue is still incredibly worrying.
About 1 in 100 times (maybe even less) I'll see this same test case never call back for loading C in this example with the fix above, making it the only failing test, and I have no idea why. It's rare enough I can't catch it and debug it.
I'm pretty much 99% sure that my suggested change is a necessary one for the algorithm here.
The key issue here is that the dependencies of a load added to a linkset are only added to the linkset itself if that load is loaded.
This seems very strange, as the point of a linkset is to track unloaded dependencies.
The issue is that it is linking linksets, where the linkset has a deep dependency on a load record still loading. The reason for this is that the linkset doesn't seem to track deep unloaded load records necessary to be loaded before the linkset is ready - it only seems to track the first-level loaded dependencies.
The suggested change is 3.c of
addLoadToLinkSet
, removing the check "if load.[[Status]] is loaded" entirely.Here is a full run of the algorithm on a sample dependency tree of three modules, with and without the change. The load records and their link sets are visualised at each stage of the algorithm, hopefully in a way that should be fairly obvious.
Any questions just ask.
The correction is then applied, resulting in the algorithm doing:
Note that we are now linking in the correct order.
If I've missed something please let me know.