asyncapi / saunter

Saunter is a code-first AsyncAPI documentation generator for dotnet.

Home Page:https://www.asyncapi.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error: Maximum call stack size exceeded

Anaster666 opened this issue · comments

Good morning,

I have a DDD project in .netCore in differents projects. I have configured the asyncApi and it works because the annotations are in the controller. But when I add this annotations in "Application" shape and modify the assembly taking one class of all the project I have this error:

Error: Maximum call stack size exceeded

I have this structure:

StartUp:

(...)
options.AssemblyMarkerTypes = new[] { typeof(MotorApplication) };  //this is one of the differents classes in the project application
(...)

ProjectApplication:

[AsyncApi]
    public class SyncMotor : DomainEventHandler<MotorDomainEvent>
    {

        public SyncMotor ()
        {
        }

        [Channel("Automotion/v1/MotorDocuments/Sync", BindingsRef = "service-amqp-binding")]
        [PublishOperation(typeof(IntegrationEvent), Summary = "")]
        public override Task Handle(MotorDomainEvent notification, CancellationToken cancellationToken)
        {
        }
    }

Thanks!!!

Hmmm 🤔 does your IntegrationEvent have a circular reference?
Can you confirm which version of Saunter you are using?

Hiii!!

I have detect the problem, is the class Exception of .netCore. If the class have one attribute of this class I will have the error of "maximum call stack".

I send you my test:

`
[AsyncApi]
public class SyncDocumentIntegrationEventWhenUserPictureProfileDeletedDomainEventHandler : DomainEventHandler
{

    private readonly IIntegrationEventBus _integrationEventBus;

    public SyncDocumentIntegrationEventWhenUserPictureProfileDeletedDomainEventHandler(IIntegrationEventBus integrationEventBus)
    {
        _integrationEventBus = integrationEventBus;
    }


    [Channel("BArchive/v1/BusinessDocuments/DeleteUserFile", BindingsRef = "service-amqp-binding")]
    [PublishOperation(typeof(HolaClass), Summary = "Inform about user picture profile is deleted.")]
    public override Task Handle(UserPictureProfileDeletedDomainEvent notification, CancellationToken cancellationToken)
    {
        return Task.CompletedTask;
    }
}

public class HolaClass
{
    public int holaaa { get; set; }
    public Exception ex { get; set; }

    public HolaClass(int userId) 
    {
    }

}`

The version is 0.8.0

Thanks for the help!

Just had a deeper look into this. From your test case the asyncapi.json document is being generated correctly, but the AsyncAPI UI is unable to render it.

As a minimal example the following will produce the Maximum call stack size exceeded error.

asyncapi: 2.2.0
info:
  title: Streetlights API
  version: 1.0.0
channels:
  publish/light/measured:
    publish:
      operationId: MeasureLight
      message:
        payload:
          $ref: '#/components/schemas/lightMeasuredEvent'
        name: lightMeasuredEvent
components:
  schemas:
    lightMeasuredEvent:
      id: lightMeasuredEvent
      type: object
      properties:
        ex:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/exception'
    exception:
      id: exception
      type: object
      properties:
        Message:
          type: string
        InnerException:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/exception'  # <--- if we remove this self-reference, the UI renders fine.

I will raise this issue with the asyncapi team.

This has been fixed by the asyncapi team and updated in Saunter #144