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

Improve error exception for debugging circular dependencies #404

Closed
luisnaranjo733 opened this issue Apr 9, 2019 · 0 comments · Fixed by #514
Closed

Improve error exception for debugging circular dependencies #404

luisnaranjo733 opened this issue Apr 9, 2019 · 0 comments · Fixed by #514

Comments

@luisnaranjo733
Copy link

luisnaranjo733 commented Apr 9, 2019

Currently, if you pass an undefined dependency into createSelector(), reselect correctly throws an exception. The string in that exception can be made a little bit more clearer, which would be helpful for clients that are hitting this and trying to find the source of the problem.

Here is how the error string is computed right now. An easy way to make this better would be to change this

    const dependencyTypes = dependencies.map(
      dep => typeof dep
    ).join(', ')

to this

    const dependencyTypes = dependencies.map(
      dep => typeof dep === 'function' ? `${dep.name}()` : typeof dep
    ).join(', ')

Circular dependencies are a common pain point in Javascript apps. If you google this error string you will find articles about people trying to solve this issue. It's not reselect's fault at all, but reselect can help make them easier to find if they happen to surface at the reselect layer.

https://decembersoft.com/posts/error-selector-creators-expect-all-input-selectors-to-be-functions/

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

Successfully merging a pull request may close this issue.

2 participants