Skip to content

JavaScript: Fix stack overflow in Type.signature for cyclic parameterized types#6867

Merged
knutwannheden merged 1 commit intomainfrom
spicy-walrus
Mar 4, 2026
Merged

JavaScript: Fix stack overflow in Type.signature for cyclic parameterized types#6867
knutwannheden merged 1 commit intomainfrom
spicy-walrus

Conversation

@knutwannheden
Copy link
Contributor

Summary

  • The Parameterized case in Type.signature() was missing a has() cycle detection check before recursing into type parameters. The Union and Intersection cases already had this guard, but Parameterized did not.
  • When shell-cached parameterized types formed cycles (e.g. A<B<A>>), the function recursed infinitely, causing RangeError: Maximum call stack size exceeded during RPC serialization.
  • Discovered while building google/zx in a Moderne run.

Test plan

  • Added unit tests for cyclic and non-cyclic parameterized type signatures
  • Verified locally that parsing google/zx no longer causes stack overflow
  • CI passes

The Parameterized case in signature() was missing a cycle detection
check that the Union and Intersection cases already had. When
shell-cached parameterized types formed cycles (e.g. A<B<A>>), the
function would recurse infinitely. This was triggered by google/zx
during Moderne builds.
@github-project-automation github-project-automation bot moved this to In Progress in OpenRewrite Mar 4, 2026
@knutwannheden knutwannheden changed the title Fix stack overflow in Type.signature for cyclic parameterized types JavaScript: Fix stack overflow in Type.signature for cyclic parameterized types Mar 4, 2026
@knutwannheden knutwannheden merged commit 8c7b901 into main Mar 4, 2026
1 check failed
@knutwannheden knutwannheden deleted the spicy-walrus branch March 4, 2026 12:21
@github-project-automation github-project-automation bot moved this from In Progress to Done in OpenRewrite Mar 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant