-
-
Notifications
You must be signed in to change notification settings - Fork 229
Description
Describe the bug.
A valid AsyncAPI document containing a circular schema inside an array tuple causes Modelina to crash at runtime with:
RangeError: Maximum call stack size exceeded
The crash occurs in AsyncAPIInputProcessor.convertToInternalSchema because the recursion guard (alreadyIteratedSchemas) is not propagated when iterating over schema.items() using Array.map().
As a result, circular schemas inside tuple-based arrays are processed with a fresh recursion state on every iteration, leading to infinite recursion.
This affects both CLI and programmatic usage and can be triggered by valid real-world schemas.
Expected behavior
Modelina should safely process circular schemas (including tuple-based arrays) without crashing, using the existing recursion guard to prevent infinite recursion.
Screenshots
Not applicable — this is a runtime crash.
How to Reproduce
- Create the following AsyncAPI document:
asyncapi: 2.6.0
info:
title: Circular Array Crash Repro
version: 1.0.0
channels:
test/channel:
publish:
message:
payload:
type: array
items:
- $ref: '#/components/schemas/Node'
- $ref: '#/components/schemas/Node'
components:
schemas:
Node:
type: object
properties:
children:
type: array
items:
- $ref: '#/components/schemas/Node'- Run Modelina programmatically:
const { TypeScriptGenerator } = require('@asyncapi/modelina');
await new TypeScriptGenerator().generate(doc);- Observe the runtime crash:
RangeError: Maximum call stack size exceeded
🖥️ Device Information [optional]
- Operating System (OS): macOS
- Browser: (N/A)
- Browser Version: (N/A)
👀 Have you checked for similar open issues?
- I checked and didn't find similar issue
🏢 Have you read the Contributing Guidelines?
- I have read the Contributing Guidelines
Are you willing to work on this issue ?
Yes I am willing to submit a PR!