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

Example: V3 Determinism solution #299

Draft
wants to merge 1 commit into
base: alsh/asset-graph-tidy
Choose a base branch
from

Conversation

alshdavid
Copy link
Contributor

@alshdavid alshdavid commented Jan 3, 2025

It appears that identifiers are generated based on the insertion order of nodes into the AssetGraph. I believe the determinism issues in V3 are a result of the PathRequest requests occurring concurrently (I think they run on the main thread in V2 making the order deterministic).

Having a deterministic insertion position on the AssetGraph is one solution (BTreeMap based graph?), or alternatively identifiers could be be excluded from identifiers.

In the meantime, a simple fix is to send a sorted graph back to JavaScript - ensuring that insertion order does not matter.

The serialized graph looks like:

{
  edges: Array<[number, number]>,   // Sorted alphabetically by `${number} ${number}`,
  nodes: Array<AssetGraphNode>,     // Sorted alphabetically by AssetGraphNode.id()
}

It works but it's kinda gross. I'm fine with this approach being scrapped or incorporated temporarily as a stop-gap.

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.

1 participant