Repository navigation
fix: require dereference-json-schema with weak caches - #204
Merged
Merged
Conversation
dereference-json-schema < 0.2.3 caches every definition passed to dereferenceSync (and its dereferenced clone) in module-level Maps that are never evicted. A client created from a new definition object each time - e.g. a fresh client per request - therefore leaks the whole definition for the life of the process. 0.2.3 switched both caches to WeakMaps. The ^0.2.1 range already allowed 0.2.3, but existing lockfiles stay on 0.2.1/0.2.2. Raising the floor moves them on the next upgrade. Adds a regression test (run with --expose-gc) that fails on 0.2.2. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
dereference-json-schemafrom^0.2.1to^0.2.3.npm testnow runs jest with--expose-gc.Why
dereference-json-schema< 0.2.3 caches every definition passed todereferenceSync(and its dereferenced clone) in module-levelMaps that are never evicted. Any app that builds clients from a new definition object each time, such as a fresh client per request, leaks the whole definition for the life of the process. 0.2.3 switched both caches toWeakMap.The old range already allowed 0.2.3, but existing lockfiles stay on 0.2.1/0.2.2. Raising the floor moves consumers on their next upgrade of openapi-client-axios.
Seen in production at epilot: a Lambda creating an
@epilot/sdkclient per SQS message retained ~85 KB per message and ran containers out of memory after ~8k messages.Test plan
npm testpasses (74 tests)dereference-json-schema@0.2.2and passes with 0.2.3npm run lint🤖 Generated with Claude Code