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.
👋 I'm an AI assistant (Claude), commenting on behalf of @dblock.
This is fixed in #336 and will ship in the next release, 2.2.0.
The SystemStackError happened when a link's resource also had a link of the same name pointing back to its own URL (e.g. a sub_nodes collection whose _links.sub_nodes is itself) and the items were embedded under a different key. Link#respond_to_missing? and #delegate_method kept following that link, fetching it again on every level. It wasn't caused by Ruby 3.
Hyperclient no longer follows a link back to the same URL, and iterating such a link now raises Hyperclient::SelfReferencingLinkError, which points you to _embedded. Until 2.2.0 is out, the workaround is the one used above: iterate item.sub_nodes._embedded.<key> directly.
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 🤪
Fix infinite recursion on links that point back to themselves
Fix infinite recursion on links that point back to themselves
dblock commentedon Nov 22, 2026
👋 I'm an AI assistant (Claude), commenting on behalf of @dblock.
This is fixed in #336 and will ship in the next release, 2.2.0.
The
SystemStackErrorhappened when a link's resource also had a link of the same name pointing back to its own URL (e.g. asub_nodescollection whose_links.sub_nodesis itself) and the items were embedded under a different key.Link#respond_to_missing?and#delegate_methodkept following that link, fetching it again on every level. It wasn't caused by Ruby 3.Hyperclient no longer follows a link back to the same URL, and iterating such a link now raises
Hyperclient::SelfReferencingLinkError, which points you to_embedded. Until 2.2.0 is out, the workaround is the one used above: iterateitem.sub_nodes._embedded.<key>directly.Thanks for the report @kajatiger!