-
-
Notifications
You must be signed in to change notification settings - Fork 233
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
Replacement-value is presumably passed by reference instead of being passed by value #349
Comments
…ope of this PR will ignore the extra component block
Is there an update on this issue? |
The usage of The worst part is that
immediately before |
I am observing weird behavior during dereference, which I am wary to call a 'bug', because most probably it's a result of JS limitations and not an algorithmic flaw.
In a
YAML
an additional property is saved both to objects BEING dereferenced and THAT CONTAINS information attached in place of a
$ref
.dereferenced YAML
I suspect the reason for such behavior is that the replacement-value is passed to the object being dereferenced by reference and not by value. I think so, because I tried changing the names of both objects so they are not the same (to exclude the possibility that the second object is hitting a cache entry in a
Set()
and thus is being served back the same value) and changes to one object are still mirrored to the other one.I have traced this behavior up to the
crawl()
function. Before it, the YAML was still intact, and after it, it already contained this unexpected change.If my guess of passing an object by reference gets confirmed, I would suggest replacing objects' assignments with cloning using the ECMAScript 2022's
structuredClone()
method that creates a deep clone of a given value using the structured clone algorithm.The code used for dereferencing: https://github.com/asyncapi/bundler/blob/master/src/parser.ts#L45
I have to differentiate internal JSON Pointers into those that SHOULD be dereferenced and those that SHOULD NOT, so I use
dereference
with conditions instead of unconditionalbundle
.(
x-origin
is a property containing the historical value of a dereferenced$ref
, meant mainly for humans' reference where the$ref
came from, thus it's not important for the story)The text was updated successfully, but these errors were encountered: