-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Failing test case for recursive types #940
Failing test case for recursive types #940
Conversation
Created failing test case for recursive types with the hopes that we can figure out how to fix it.
1d2ccd8
to
7513c4b
Compare
Thanks @DullReferenceException ! Hopefully someone can pick this up and submit a PR. Any ideas @herom on what may have introduced this? |
1 similar comment
Aw yeah, found a fix which is basically just maintaining a recursion backtrace. Does this fix look ok? |
Amazing @DullReferenceException ! Thanks! |
Thank you for the quick merge! |
Np! |
@jsdevel: any estimate on when this will be published? |
Published as |
// We've recursed back to ourselves; break. | ||
return null; | ||
} else { | ||
backtrace = backtrace.concat([parameterTypeObj]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just to understand it better: what's the purpose of using concat()
and creating a new Array
instead of just push()
ing ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we mutate the array (in the case when it's passed in), then after this function returns, the array will erroneously carry the new value to the next iteration, making it no-longer reflect the backtrace.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm always eager to learn new things but I'm afraid I not able to follow you here 😸
Would it be possible for you to create a jsbin or gist or something like that in order for me to get the difference? Maybe it's because it's already late in the evening (for me) 🇦🇹 I would be very thankful for this 👍 💯
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. Let's say we're traversing this schema:
foo
bar
foo
baz
blah
zub
If we used .push()
, here's what the array would look like as we do the depth-first traversal:
[foo]
[foo, bar]
// (here we encounter foo again, so we skip)
[foo, bar, baz]
[foo, bar, baz, blah] // Incorrect; should be [foo, blah]
[foo, bar, baz, blah, zub] // Incorrect; should be [zub]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks a ton @DullReferenceException - it seems it was really too late for me 😄 - totally clear now 👍
XML generation in a service with a recursively-defined type is causing a stack overflow. There appears to be infinite recursion going on. Here's the repeating stack trace fragment:
This boiled-down version of our code in the new test case reproduces it.
Note that versions before
0.15.0
did not have this bug.