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

Cyclic dependency detection #110

Open
pixtim opened this issue May 19, 2020 · 0 comments
Open

Cyclic dependency detection #110

pixtim opened this issue May 19, 2020 · 0 comments

Comments

@pixtim
Copy link

pixtim commented May 19, 2020

It looks like the container crashes with a stack-overflow when a cyclic dependancy has been configured.


internal/console/constructor.js:241,
    if (isStackOverflowError(e)),
        ^

RangeError: Maximum call stack size exceeded,
    at Object.Console.<computed> (internal/console/constructor.js:241:9),
    at Object.log (internal/console/constructor.js:282:26),
    at Container.symbol2string (/scm/hex/packages/sector/node_modules/container-ioc/dist/lib/container.js:142:17),
    at Container.getTokenString (/scm/hex/packages/sector/node_modules/container-ioc/dist/lib/container.js:134:25),
    at Container.buildTraceMessage (/scm/hex/packages/sector/node_modules/container-ioc/dist/lib/container.js:126:31),
    at Container.resolveInternal (/scm/hex/packages/sector/node_modules/container-ioc/dist/lib/container.js:36:29),
    at /scm/hex/packages/sector/node_modules/container-ioc/dist/lib/container.js:99:74,
    at Array.map (<anonymous>),
    at Container.instantiateWithFactory (/scm/hex/packages/sector/node_modules/container-ioc/dist/lib/container.js:99:47),
    at Container.resolveInternal (/scm/hex/packages/sector/node_modules/container-ioc/dist/lib/container.js:47:31),
    at /scm/hex/packages/sector/node_modules/container-ioc/dist/lib/container.js:99:74,
    at Array.map (<anonymous>),
    at Container.instantiateWithFactory (/scm/hex/packages/sector/node_modules/container-ioc/dist/lib/container.js:99:47),
    at Container.resolveInternal (/scm/hex/packages/sector/node_modules/container-ioc/dist/lib/container.js:47:31),
    at /scm/hex/packages/sector/node_modules/container-ioc/dist/lib/container.js:99:74,
    at Array.map (<anonymous>)

This can be reproduced by creating services A and B with their corresponding tokens and cross-injecting them:

provide service A
provide service B
A injects B
B injects A

I've worked around this issue in my project by avoid cyclic dependencies. Please let me know if you'd like me to create a minimal reproduction.

Thanks for the awesome package. It's helping a lot! 🦄

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

No branches or pull requests

1 participant