Skip to content

Circular references causes stack overflow #67

Closed

Description

@jonaslagoni

Describe the bug

While fiddling around I tried adding the machine readable file for AsyncAPI 2.0.0 as a payload and I noticed that it can be parsed fine however the template might be missing a check somewhere because it causes a RangeError: Maximum call stack size exceeded.

How to Reproduce

Place the following AsyncAPI file and the machine readable file in the same directory.

{
  "asyncapi": "2.0.0",
  "info": {
    "title": "test",
    "version": "1.0.0"
  },
	"channels": {
		"test": {
			"subscribe": {
				"message": {
					"payload": {
                                             "$ref": "./2.0.0.json"
					}
				}
			}
		}
	}
}

Then execute ag ./test.json @asyncapi/html-template --output ./out --install

Then you should see something similar to:

 ag ./test.json @asyncapi/html-template --output ./out --install
npm http fetch GET 200 https://registry.npmjs.org/@asyncapi%2fhtml-template 17ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/@asyncapi%2fgenerator-filters 143ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/openapi-sampler 44ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/markdown-it 77ms (from cache)
npm http fetch GET 200 https://registry.npmjs.org/entities 8ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/json-pointer 34ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/foreach 37ms (from cache)
npm WARN [email protected] requires a peer of typescript@>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

+ @asyncapi/[email protected]
updated 1 package in 9.027s

60 packages are looking for funding
  run `npm fund` for details

Something went wrong:
Template render error: (C:\Users\Lagoni\AppData\Roaming\npm\node_modules\@asyncapi\generator\node_modules\@asyncapi\html-template\template\index.html)
  Template render error: (C:\Users\Lagoni\AppData\Roaming\npm\node_modules\@asyncapi\generator\node_modules\@asyncapi\html-template\partials\content.html)
  Template render error: (C:\Users\Lagoni\AppData\Roaming\npm\node_modules\@asyncapi\generator\node_modules\@asyncapi\html-template\partials\operations.html)
  RangeError: Maximum call stack size exceeded
    at Object._prettifyError (C:\Users\Lagoni\AppData\Roaming\npm\node_modules\@asyncapi\generator\node_modules\nunjucks\src\lib.js:36:11)
    at C:\Users\Lagoni\AppData\Roaming\npm\node_modules\@asyncapi\generator\node_modules\nunjucks\src\environment.js:561:19
    at eval (eval at _compile (C:\Users\Lagoni\AppData\Roaming\npm\node_modules\@asyncapi\generator\node_modules\nunjucks\src\environment.js:631:18), <anonymous>:118:12)
    at C:\Users\Lagoni\AppData\Roaming\npm\node_modules\@asyncapi\generator\node_modules\nunjucks\src\environment.js:569:11
    at eval (eval at _compile (C:\Users\Lagoni\AppData\Roaming\npm\node_modules\@asyncapi\generator\node_modules\nunjucks\src\environment.js:631:18), <anonymous>:64:12)
    at C:\Users\Lagoni\AppData\Roaming\npm\node_modules\@asyncapi\generator\node_modules\nunjucks\src\environment.js:569:11
    at eval (eval at _compile (C:\Users\Lagoni\AppData\Roaming\npm\node_modules\@asyncapi\generator\node_modules\nunjucks\src\environment.js:631:18), <anonymous>:10:11)
    at C:\Users\Lagoni\AppData\Roaming\npm\node_modules\@asyncapi\generator\node_modules\nunjucks\src\environment.js:611:9
    at eval (eval at _compile (C:\Users\Lagoni\AppData\Roaming\npm\node_modules\@asyncapi\generator\node_modules\nunjucks\src\environment.js:631:18), <anonymous>:54:12)
    at C:\Users\Lagoni\AppData\Roaming\npm\node_modules\@asyncapi\generator\node_modules\nunjucks\src\environment.js:611:9
    at eval (eval at _compile (C:\Users\Lagoni\AppData\Roaming\npm\node_modules\@asyncapi\generator\node_modules\nunjucks\src\environment.js:631:18), <anonymous>:21:11)
    at C:\Users\Lagoni\AppData\Roaming\npm\node_modules\@asyncapi\generator\node_modules\nunjucks\src\environment.js:611:9
    at Template.root [as rootRenderFunc] (eval at _compile (C:\Users\Lagoni\AppData\Roaming\npm\node_modules\@asyncapi\generator\node_modules\nunjucks\src\environment.js:631:18), <anonymous>:42:3)
    at Template.getExported (C:\Users\Lagoni\AppData\Roaming\npm\node_modules\@asyncapi\generator\node_modules\nunjucks\src\environment.js:609:10)
    at eval (eval at _compile (C:\Users\Lagoni\AppData\Roaming\npm\node_modules\@asyncapi\generator\node_modules\nunjucks\src\environment.js:631:18), <anonymous>:20:5)
    at Environment.getTemplate (C:\Users\Lagoni\AppData\Roaming\npm\node_modules\@asyncapi\generator\node_modules\nunjucks\src\environment.js:277:9)

Versions:

npm list -g | grep @asyncapi
+-- @asyncapi/[email protected]
| +-- @asyncapi/[email protected]
| +-- @asyncapi/[email protected]
| | `-- @asyncapi/[email protected]
| +-- @asyncapi/[email protected]
| +-- @asyncapi/[email protected]
| | +-- @asyncapi/[email protected]
| +-- @asyncapi/[email protected]

Expected behavior

Should be rendered successfully.

Activity

  1. added
    bug
    on Sep 15, 2020
  2. github-actions commented on Sep 15, 2020

    @github-actions

    Welcome to AsyncAPI. Thanks a lot for reporting your first issue.
    Keep in mind there are also other channels you can use to interact with AsyncAPI community. For more details check out this issue.

  3. derberg commented on Sep 16, 2020

    @derberg
    Member

    The issue is caused because allOf

    issue is in our template and in generic filter that uses openapi-sampler, probably also because of allOf

    it definitely need some deeper investigation and fix will have to be pushed again to the upstream

  4. github-actions commented on Nov 16, 2020

    @github-actions

    This issue has been automatically marked as stale because it has not had recent activity 😴
    It will be closed in 30 days if no further activity occurs. To unstale this issue, add a comment with detailed explanation.
    Thank you for your contributions ❤️

  5. github-actions commented on Jan 16, 2021

    @github-actions

    This issue has been automatically marked as stale because it has not had recent activity 😴
    It will be closed in 60 days if no further activity occurs. To unstale this issue, add a comment with detailed explanation.
    Thank you for your contributions ❤️

  6. github-actions commented on Mar 20, 2021

    @github-actions

    This issue has been automatically marked as stale because it has not had recent activity 😴
    It will be closed in 60 days if no further activity occurs. To unstale this issue, add a comment with detailed explanation.
    Thank you for your contributions ❤️

  7. github-actions commented on May 22, 2021

    @github-actions

    This issue has been automatically marked as stale because it has not had recent activity 😴
    It will be closed in 60 days if no further activity occurs. To unstale this issue, add a comment with detailed explanation.
    Thank you for your contributions ❤️

  8. github-actions commented on Jul 24, 2021

    @github-actions

    This issue has been automatically marked as stale because it has not had recent activity 😴
    It will be closed in 60 days if no further activity occurs. To unstale this issue, add a comment with detailed explanation.
    Thank you for your contributions ❤️

  9. magicmatatjahu commented on Jul 26, 2021

    @magicmatatjahu
    Member

    Similar issue #165

    It's related to issue in the ParserJS repo - asyncapi/parser-js#293 We need to wait for the PR in the mentioned repo.

  10. github-actions commented on Sep 25, 2021

    @github-actions

    This issue has been automatically marked as stale because it has not had recent activity 😴
    It will be closed in 60 days if no further activity occurs. To unstale this issue, add a comment with detailed explanation.
    Thank you for your contributions ❤️

  11. magicmatatjahu commented on Sep 27, 2021

    @magicmatatjahu
    Member

    I close the issue in favour of #165

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions