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

Move away from Promise.all way and check if we need to finish manually #26395

Merged
merged 1 commit into from Jun 13, 2020

Commits on Jun 13, 2020

  1. Move away from Promise.all way and check if we need to finish manually

    In the previous Promise.all way, we registered a promise for every
    module script which means we will need to do many complex checkings like
    "is this top level?" and it will make us much more difficult to understand
    how the module script algorithm works.
    
    In the new manual checking way, we will only register promises for top
    level modules to notify its owner (e.g. the script element) to finish
    the load. So, we can understand it much more easily and would be more
    spec-aligned.
    
    Also, I think the `Ready` and `FetchFailed` status are quite confusing
    and we actually don't need them so they're removed in this patch. Then,
    we will always go to `Finished` instead.
    
    It would basically be following steps:
    
                                              +-----------------+
                                              | Failed to fetch | ----------+
    +--------------+       +----------+     / +-----------------+           |
    | Fetch module | ----> | Fetching | ---+                                v
    +--------------+       +----------+     \ +---------+        +---------------------+
                                              | Fetched |        | Advance to Finished |
                                              +---------+        +---------------------+
                                                   |                        ^
                                                   v                        |
                                          +-------------------+             |
                                          | Fetch descendants | ----- if no descendants
                                          +-------------------+
                                                   |
                                                   V
                                         +----------------------+
                                         | Fetching Descendants |
                                         +----------------------+
    
    In `Advance to Finished`, it means that module script is about to finished so it will
    
    1. Notify all of its `ready` and `not finished` parents to finish
    2. Link (instantiate) the module
    3. Resolve its promise to notify owner(s) to finish
    CYBAI committed Jun 13, 2020
You can’t perform that action at this time.