Redocly / Redocly/redocly-cli

Error `Maximum call stack size exceeded` when schema grows

Open
#2,640 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

JSON Schema p2 Respect Type: Bug
Dominant language
TypeScript
Stars
1.5k
Forks
228
Avg merge
1d 14h
Merged PRs (30d)
48

Description

Describe the bug
When the openapi specification grows and has a huge list that we need to distinguish between, I got the error Ajv error: Maximum call stack size exceeded while executing respect.

To Reproduce

  1. Using provided example run mock server and then run redocly respect openapi.arazzo.yaml
  2. Receive Ajv error: Maximum call stack size exceeded

Expected behavior
Respect command executes successfully.

Logs
Image

OpenAPI description
Provided archive.

Redocly version(s)
2.20.2

Node.js version(s)
24

OS, environment
macOs

Additional context
I investigated a little bit and when i comment discriminator: true in Ajv instance inside the file: packages/respect-core/src/modules/flow-runner/schema/schema-checker.ts i didn't receive an error.

One of our customer reported, that the error occurs when the number of enum values exceeds 126.

call-stack-repro.zip

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with packages/respect-core/src/modules/flow-runner/schema/schema-checker.ts and reproduce the failure with the provided call-stack-repro.zip, a mock server, and redocly respect openapi.arazzo.yaml. Compare behavior with discriminator: true enabled and disabled, focusing on specifications with more than 126 enum values. Done means the Respect command executes successfully for the reported large schema.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.