swagger-api / swagger-api/swagger-ui

RangeError: Maximum call stack size exceeded

Open
#7,394 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
29k
Forks
9.3k
Avg merge
2d 23h
Merged PRs (30d)
25

Description

Q&A (please complete the following information)
  • OS: Win7
  • Browser: Chrome
  • Version: 91.0.4472
  • Project Type - ASP.NET 5.0
  • Method of installation: Nuget Manager in Visual Studio 2019
  • Swagger-UI version: 6.1.4
  • Swagger/OpenAPI version: OpenApi 3.0.1
Content & configuration

Example Swagger/OpenAPI definition:

{
  "openapi": "3.0.1",
  "info": {
    "title": "MyAPI",
    "version": "v1"
  },
  "paths": {
    "/api/packages": {
      "get": {
        "tags": [
          "Packages"
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "text/plain": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Package"
                  }
                }
              },
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Package"
                  }
                }
              },
              "text/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Package"
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "FileData": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "nullable": true
          },
          "path": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "nullable": true
          },
          "size": {
            "type": "integer",
            "format": "int64"
          },
          "hash": {
            "type": "string",
            "nullable": true
          },
          "locator": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "nullable": true,
            "readOnly": true
          },
          "isCompressed": {
            "type": "boolean",
            "readOnly": true
          }
        },
        "additionalProperties": false
      },
      "Package": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "nullable": true
          },
          "name": {
            "type": "string",
            "nullable": true
          },
          "version": {
            "type": "string",
            "nullable": true
          },
          "compressedFile": {
            "$ref": "#/components/schemas/FileData"
          },
          "files": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/FileData"
            },
            "nullable": true
          },
          "fileServerUrl": {
            "type": "string",
            "nullable": true
          },
          "timestamp": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      }
    }
  }
}

Swagger-UI configuration options:

public void ConfigureServices(IServiceCollection services)
{
    services.AddSwaggerGen(c => c.SwaggerDoc("v1", new OpenApiInfo { Title = "MyAPI", Version = "v1" });
}

public void Configure(IApplicationBuilder app)
{
    app.UseSwagger();
    app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "MyAPI v1"));
}
Describe the bug you're encountering

We are upgrading from ASP.NET 4.72 to 5.0 and had a GET end point which returns collection of a schema. The older code works with Swashbuckle.AspNetCore v4.0.1 and the latest code has v6.1.4.

The endpoint returns json of 542,580 characters in older version & in latest version fails with message RangeError: Maximum call stack size exceeded. The endpoint works from postman in both versions, its in swagger UI that this happens. Also, UI becomes unresponsive and hangs. In logs, the .Net logs says the data is returns in couple of seconds.

2021-06-29 15:50:28.2021 INFO [70] [Microsoft.AspNetCore.Hosting.Diagnostics] Request starting HTTP/1.1 GET http://myserver:12912/api/packages - - 
2021-06-29 15:50:28.2021 INFO [70] [Microsoft.AspNetCore.Routing.EndpointMiddleware] Executing endpoint 'MyAPI.PackagesController.Get (MyAPI)' 
2021-06-29 15:50:28.2021 INFO [70] [Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker] Route matched with {action = "Get", controller = "Packages"}. Executing controller action with signature System.Threading.Tasks.Task`1[System.Collections.Generic.IEnumerable`1[MyAPI.Package]] Get() on controller MyAPI.PackagesController (MyAPI). 
2021-06-29 15:50:28.5674 INFO [70] [Microsoft.AspNetCore.Mvc.Infrastructure.ObjectResultExecutor] Executing ObjectResult, writing value of type 'System.Collections.Generic.List`1[[MyAPI.Package, MyAPI, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null]]'. 
2021-06-29 15:50:28.9621 INFO [65] [Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker] Executed action MyAPI.PackagesController.Get (MyAPI) in 757.9003ms 
2021-06-29 15:50:28.9621 INFO [65] [Microsoft.AspNetCore.Routing.EndpointMiddleware] Executed endpoint 'MyAPI.PackagesController.Get (MyAPI)' 
2021-06-29 15:50:28.9621 INFO [65] [Microsoft.AspNetCore.Hosting.Diagnostics] Request finished HTTP/1.1 GET http://myserver:12912/api/packages - - - 200 5042580 application/json;+charset=utf-8 760.1613ms 
To reproduce...

Steps to reproduce the behavior:
In the latest version, hit an api in swagger UI which return a heavy schema json returning around 0.5 million characters.

Expected behavior

The endpoint should not fail to return results and should be backward compatible with previous versions.

Screenshots

New version
image

Older Version
Capture_Working_4 0 1

Postman
Postman

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 by reproducing the issue in Swagger UI with the provided ASP.NET endpoint and its roughly 5 MB JSON response in Chrome. Trace the response-rendering entry point that produces the RangeError or UI hang; done means the endpoint renders without a stack overflow or becoming unresponsive, while preserving the existing response behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, javascript
Domain
frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.