Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(link-parser): avoid crashing with invalid links #1136

Merged

Conversation

sandrafreihofer
Copy link
Contributor

As of version 1.1.14, generating our documentation crashes and throws the following error:

Unhandled Rejection at: Promise {
  <rejected> RangeError: Maximum call stack size exceeded
      at RegExp.exec (<anonymous>)
      at replaceLinkTag (/Users/sandra/dev/siemens/simpl-element/node_modules/@compodoc/compodoc/dist/index-cli-8ef9c2ed.js:527:33)
      at Object._resolveLinks [as resolveLinks] (/Users/sandra/dev/siemens/simpl-element/node_modules/@compodoc/compodoc/dist/index-cli-8ef9c2ed.js:543:16)
      at /Users/sandra/dev/siemens/simpl-element/node_modules/@compodoc/compodoc/dist/index-cli-8ef9c2ed.js:903:43
      at arrayEach (/Users/sandra/dev/siemens/simpl-element/node_modules/lodash/lodash.js:530:11)
      at Object.forEach (/Users/sandra/dev/siemens/simpl-element/node_modules/lodash/lodash.js:9410:14)
      at markedtags (/Users/sandra/dev/siemens/simpl-element/node_modules/@compodoc/compodoc/dist/index-cli-8ef9c2ed.js:901:18)
      at ClassHelper.addAccessor (/Users/sandra/dev/siemens/simpl-element/node_modules/@compodoc/compodoc/dist/index-cli-8ef9c2ed.js:6809:46)
      at ClassHelper.visitMembers (/Users/sandra/dev/siemens/simpl-element/node_modules/@compodoc/compodoc/dist/index-cli-8ef9c2ed.js:7228:38)
      at ClassHelper.visitClassDeclaration (/Users/sandra/dev/siemens/simpl-element/node_modules/@compodoc/compodoc/dist/index-cli-8ef9c2ed.js:7020:24)
} reason: RangeError: Maximum call stack size exceeded
    at RegExp.exec (<anonymous>)
    at replaceLinkTag (/Users/sandra/dev/siemens/simpl-element/node_modules/@compodoc/compodoc/dist/index-cli-8ef9c2ed.js:527:33)
    at Object._resolveLinks [as resolveLinks] (/Users/sandra/dev/siemens/simpl-element/node_modules/@compodoc/compodoc/dist/index-cli-8ef9c2ed.js:543:16)
    at /Users/sandra/dev/siemens/simpl-element/node_modules/@compodoc/compodoc/dist/index-cli-8ef9c2ed.js:903:43
    at arrayEach (/Users/sandra/dev/siemens/simpl-element/node_modules/lodash/lodash.js:530:11)
    at Object.forEach (/Users/sandra/dev/siemens/simpl-element/node_modules/lodash/lodash.js:9410:14)
    at markedtags (/Users/sandra/dev/siemens/simpl-element/node_modules/@compodoc/compodoc/dist/index-cli-8ef9c2ed.js:901:18)
    at ClassHelper.addAccessor (/Users/sandra/dev/siemens/simpl-element/node_modules/@compodoc/compodoc/dist/index-cli-8ef9c2ed.js:6809:46)
    at ClassHelper.visitMembers (/Users/sandra/dev/siemens/simpl-element/node_modules/@compodoc/compodoc/dist/index-cli-8ef9c2ed.js:7228:38)
    at ClassHelper.visitClassDeclaration (/Users/sandra/dev/siemens/simpl-element/node_modules/@compodoc/compodoc/dist/index-cli-8ef9c2ed.js:7020:24)
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

The problem is that when a link is unresolved, the LinkParser tries to replace the string and then forms a new string, which in turn is matched for the regular expression and then repeated over and over again. This results in something like the following:

string: `true`, if {@link undefined} is true and
the form is valid.

string: `true`, if {@link []([]([](undefined)))} is true and
the form is valid.

string: `true`, if {@link []([]([]([]([]([]([](undefined)))))))} is true and
the form is valid.

...

string: `true`, if {@link []([]([]([]([]([]([]([]([]([]([]([]([]([]([]([]([]([]([]([]([]([]([]([]([]([]([]([]([]([]([](undefined)))))))))))))))))))))))))))))))} is true and
the form is valid.

...

Apparently since version 1.1.14 the input data for resolving the links are different.

This PR simply ensures that for unresolved links the execution does not abort, but returns the unresolved links 1:1.

@vogloblinsky
Copy link
Contributor

Thanks for this PR, could you add a test please ?

@sandrafreihofer
Copy link
Contributor Author

Ah there are failing spec's anyway. I will fix it..

@vogloblinsky
Copy link
Contributor

Thanks for the PR

@vogloblinsky vogloblinsky merged commit 1891878 into compodoc:develop Oct 25, 2021
@sandrafreihofer
Copy link
Contributor Author

Thank you so much for merging. Is it planned to release a new version soon?

@vogloblinsky
Copy link
Contributor

Yes this week.

@sandrafreihofer
Copy link
Contributor Author

Awesome! Much appreciated 🙏🎉

@sandrafreihofer
Copy link
Contributor Author

Yes this week.

@vogloblinsky Is it possible for you to release a new version? In the meantime there are other users having the same problem with Maximum call stack size exceeded which should be fixed with this PR.

@TheAngularGuy
Copy link

Thanks for the PR @sandrafreihofer.
Waiting for the release of the new version 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants