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

Enters infinite loop when flow-type definition references itself #1032

Closed
aray12 opened this issue Jan 19, 2017 · 3 comments
Closed

Enters infinite loop when flow-type definition references itself #1032

aray12 opened this issue Jan 19, 2017 · 3 comments

Comments

@aray12
Copy link

aray12 commented Jan 19, 2017

I found that if you try to create prop-types using flowtype definitions and accidentally reference yourself within it you enter into a infinite loop and run out of memory

e.g.

type Props = {
  someProp: string,
  anotherProp: Props,
};

You get:

Maximum call stack size exceeded
RangeError: Maximum call stack size exceeded
    at buildTypeAnnotationDeclarationTypes (/node_modules/eslint-plugin-react/lib/rules/prop-types.js:403:35)

Obviously the application code itself is broken, but I think this should fail gracefully.

If this is a problem I should be reporting directly to eslint, please let me know

@ljharb
Copy link
Member

ljharb commented Jan 20, 2017

I think this is a bug; the recursion should keep a Set of seen values, to handle cycles.

@minedeljkovic
Copy link

Obviously the application code itself is broken, but I think this should fail gracefully

There is a valid need for recursive types even in prop-types, it is not always result of a mistake. We have a lot in our app, so we had to temporary remove react/prop-types rule.

Older dupe of this is #913

@ljharb
Copy link
Member

ljharb commented Mar 31, 2017

Closing as a dupe.

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

No branches or pull requests

3 participants