Skip to content

[Bug]: typescpec model. RangeError: Maximum call stack size exceeded #9603

@imteammy

Description

@imteammy

Describe the bug

Issue Title
Internal compiler error: RangeError: Maximum call stack size exceeded on large cyclic relationships (58+ models)

Issue Description
Describe the bug I encountered an internal compiler error (RangeError: Maximum call stack size exceeded) when compiling TypeSpec models generated from a Prisma schema. The error occurs when a central model (e.g., tb_user,tb_center) has circular relationships with a large number of other models (over 58 relations).

To Reproduce

Create a TypeSpec file where one model has circular references to 58+ other models.

Run the TypeSpec compiler.

The compiler fails with a stack overflow error.

Current Workaround: To bypass this error, I implemented a threshold in my generation script: if a model exceeds 30 relationships, I automatically replace the specific model references with Record[] and use the @doc decorator to manually document the intended relation.

Reproduction

playground

Playground Error: URI too long

My Typespec Code
https://anotepad.com/note/read/bq9bbwef

Checklist

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions