Open
Conversation
gurgunday
reviewed
Jun 26, 2024
Member
There was a problem hiding this comment.
This should work, i don't know about the performance of that package, but this could be a lot faster way of setting unique identifiers:
const idMap = new WeakMap();
const getId = (obj) => {
if (!idMap.has(obj)) {
idMap.set(obj, Symbol('id'));
}
return idMap.get(obj);
};
const id = getId(object);
mcollina
approved these changes
Jul 1, 2024
Member
mcollina
left a comment
There was a problem hiding this comment.
lgtm
I'm a bit scared of this as it would likely increase our build/startup time.
ivan-tymoshenko
requested changes
Jul 1, 2024
Member
|
I found the problem. I'm working on the solution. Unfortunatelly merging schemas with recurcive references is the most complecated part of this library and take tons of time every time when we need to fix the bug. |
|
hi @ivan-tymoshenko , any progress on this? Can I maybe try to take it from wherever you've got to? |
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.
npm run testandnpm run benchmarkdocumentation is changed or addedand the Code of conduct
Hello, this PR fixes #724.
When diving in the bug, I found that the
context.mergedSchemasIdsMap, added by @ivan-tymoshenko, is using objects as keys. This caused the schema to infinitely try to build and results intoMaximum call stack size exceedederror.So I replaced the key by a hash of the object, then I got another problem :
anyOf inside allOftest failed because, to my understanding, we try to cache different merged schemas using the same key incontext.mergedSchemasIds(like merged schemas frombuildOneOfand frombuildAllOffunctions).I am not sure of the solution. Thank you for your review !