You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Ruby 3 upgrade throws kernel error for the overwritten each method #232
If current.send(@key) (via method_missing/delegation) resolves to something that ultimately calls back into the same Link#each again — for example, when a link's key name (like sub_nodes) matches a link/embedded name on the resource it points to, forming a cycle — coll.each(&block) recurses forever, eventually blowing the stack with SystemStackError: stack level too deep instead of a clear error.
We confirmed this with a minimal repro: a resource whose sub_nodes link points to another resource that itself links sub_nodes back to the same URL, so calling .each (or anything that delegates through each, like .map) recurses infinitely.
Two possible fixes, would like the maintainers' input on preferred approach:
Cycle detection — track visited resources/URLs during the each/pagination walk and raise a clear Hyperclient::CircularLinkError (or similar) instead of silently blowing the stack.
Iteration cap — a simpler, more generic safety valve that raises after some large number of iterations, without needing to track visited state.
Happy to submit a PR for either approach — let us know which you'd prefer, or if there's a different angle you'd like us to take.
cc @kajatiger — if you have a more specific real-world repro, it'd help confirm we're fixing the right scenario.
Activity
dblock commentedon Jan 12, 2022
Start by adding Ruby 3 to https://github.com/codegram/hyperclient/blob/master/.travis.yml, do we have a repro of this out of the box with existing specs? If not, try building a repro?
kajatiger commentedon Jan 13, 2022
We fixed this in one spot now with adding
embedded:https://github.com/artsy/impulse/pull/805#discussion_r783322301
dblock commentedon Jan 13, 2022
Looks like impulse is a private repo @kajatiger.
dblock commentedon Feb 16, 2023
I fixed CI/CD with GHA on this repo and added Ruby 3.2 without issues. Interested in taking this on @kajatiger?
dblock commentedon Aug 26, 2026
👋 I'm an AI assistant, commenting on behalf of @dblock.
We were able to reproduce this
SystemStackErrorlocally. The root cause is inLink#each(link.rb#L28):If
current.send(@key)(viamethod_missing/delegation) resolves to something that ultimately calls back into the sameLink#eachagain — for example, when a link's key name (likesub_nodes) matches a link/embedded name on the resource it points to, forming a cycle —coll.each(&block)recurses forever, eventually blowing the stack withSystemStackError: stack level too deepinstead of a clear error.We confirmed this with a minimal repro: a resource whose
sub_nodeslink points to another resource that itself linkssub_nodesback to the same URL, so calling.each(or anything that delegates througheach, like.map) recurses infinitely.Two possible fixes, would like the maintainers' input on preferred approach:
each/pagination walk and raise a clearHyperclient::CircularLinkError(or similar) instead of silently blowing the stack.Happy to submit a PR for either approach — let us know which you'd prefer, or if there's a different angle you'd like us to take.
cc @kajatiger — if you have a more specific real-world repro, it'd help confirm we're fixing the right scenario.
kajatiger commentedon Aug 27, 2026
No sorry, I have not looked into this problem in 3-4 years and am working in a different codebase now 🤪