Skip to content

Isolate concurrent schema resolution state - #371

Open
RKS (rksharma-owg) wants to merge 1 commit into
microsoft:mainfrom
rksharma-owg:codex/fix-concurrent-schema-resolution
Open

RKS (rksharma-owg) wants to merge 1 commit into
microsoft:mainfrom
rksharma-owg:codex/fix-concurrent-schema-resolution

Conversation

@rksharma-owg

@rksharma-owg RKS (rksharma-owg) commented Sep 13, 2026 •

Copy link
Copy Markdown

When two roots resolve the same external schema concurrently, the second can finish while a nested request is still pending. Its returned schema then changes after resolution; failed nested requests can also be missing from its diagnostics.

Reference merging currently shares nested objects from cached unresolved schemas. Deleting a $ref in one resolution therefore makes another resolution treat the same node as complete.

This change gives each resolution its own mutable schema graph while retaining the shared download cache and existing merge behavior. Anchor lookup belongs to that graph, and embedded resources keep local aliases without exposing those nodes through globally cached handles. The copies preserve shared nodes and cycles within each copied document.

Validation on Node 22.23.1, macOS arm64:

  • Added eight controlled concurrency regressions covering document references, overlapping standalone resolution, anchors, embedded IDs, and successful/failed nested requests. All eight fail against unchanged 75a46d7d because the second result resolves early, and pass with this patch.
  • Added a passing compatibility check for cyclic references, dependency invalidation, and stability of previously resolved results.
  • npm test: compilation, 5,355 tests, and 9 lint checks passed. The unchanged baseline passed 5,346 tests and 9 lint checks.

The isolation adds in-memory copying per resolution; no performance improvement is claimed. Download reuse is asserted in the regressions. Public API signatures and reference merge rules are unchanged.

Fixes #350.

AI assistance: implemented and validated with OpenAI Codex.

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.

Concurrent schema resolutions can complete before shared nested refs resolve

1 participant