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

Sort the connections back into topological order after traversing runtimes #75

Merged
merged 3 commits into from
Sep 16, 2024

Conversation

benjervis
Copy link
Contributor

A while back in Parcel, we reversed the order that runtimes were processed in, so that child runtimes could be processed before parent bundles who would need to know about them. That didn't quite cut it, so we moved to reverse topological order.

This works fine for Jira, but in Confluence it causes an issue where a bundle gets loaded thinking that some of its dependencies are already loaded when they aren't.

We thought we'd fixed this with connections.reverse(), but that doesn't actually restore topological order, and it seems that Confluence has found the edge case.

The fix here is to actually restore topological order, by processing the bundles in reverse, and then re-traversing and building up the connection list that way.

@benjervis benjervis merged commit b617f50 into main Sep 16, 2024
17 checks passed
@benjervis benjervis deleted the fix-runtime-ordering branch September 16, 2024 05:17
// As manifest bundles may be added during runtimes we process them in reverse topological
// sort order. This allows bundles to be added to their bundle groups before they are referenced
// by other bundle groups by loader runtimes
// Sort bundles into reverse topological order
Copy link
Contributor

Choose a reason for hiding this comment

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

This is topological order, not reverse

// Sort the bundles back into forward topological order
let connections: Array<RuntimeConnection> = [];

bundleGraph.traverseBundles({
Copy link
Contributor

Choose a reason for hiding this comment

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

This isn't reverse topological order, I don't think

Copy link
Contributor

Choose a reason for hiding this comment

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

This should be

const connections = [];
bundleGraph.traverseBundles({
    exit(bundle) {
        connections.push(...connectionMap.get(bundle));
    }
});
connections.reverse();

@@ -192,8 +221,14 @@ export default async function applyRuntimes<TResult: RequestResult>({
}
}

// Correct connection order after generating runtimes in reverse order
connections.reverse();
// Sort the bundles back into forward topological order
Copy link
Contributor

Choose a reason for hiding this comment

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

You're now going for reverse topological order

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants