Skip to content

fix: avoid repeated traversal of shared schema graphs - #1231

Open
sean2077 wants to merge 1 commit into
asyncapi:masterfrom
sean2077:fix/memoize-circular-ref-traversal
Open

fix: avoid repeated traversal of shared schema graphs#1231
sean2077 wants to merge 1 commit into
asyncapi:masterfrom
sean2077:fix/memoize-circular-ref-traversal

Conversation

@sean2077

Copy link
Copy Markdown

Description

  • Keep the active recursion stack separate from a memo of fully processed objects, so shared dereferenced schema subgraphs are not traversed once per parent path.
  • Traverse a successfully resolved reference immediately and only memoize a subtree when every nested reference was resolved; unresolved path-dependent references remain eligible for a later traversal.
  • Add a deterministic regression test whose 12-level shared graph visits the leaf 4096 times before this change and once after it.

Verification

  • npm run test:unit --workspace=@asyncapi/parser -- --runInBand --coverage=false — 2529 tests passed.
  • npm run lint --workspace=@asyncapi/parser — passed.
  • npm run build --workspace=@asyncapi/parser — passed.
  • npm run test:browser --workspace=@asyncapi/parser -- --runInBand — passed.

Related issue(s)

Fixes #1230

Avoid repeatedly walking shared dereferenced schema subgraphs while retaining path-sensitive retries for unresolved references.

Closes asyncapi#1230
@changeset-bot

changeset-bot Bot commented Aug 23, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 3eeefba

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Welcome to AsyncAPI. Thanks a lot for creating your first pull request. Please check out our contributors guide useful for opening a pull request.
Keep in mind there are also other channels you can use to interact with AsyncAPI community. For more details check out this issue.

@sonarqubecloud

Copy link
Copy Markdown

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.

Parser repeatedly traverses shared schema graphs during circular-reference resolution

1 participant