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

Infinite loop in lerna project setup #144

Open
lostintime opened this issue Nov 3, 2018 · 0 comments
Open

Infinite loop in lerna project setup #144

lostintime opened this issue Nov 3, 2018 · 0 comments

Comments

@lostintime
Copy link
Contributor

In a lerna project setup, when multiple packages depend on funfix-effect (IO), combining IO's from those packages leads to an infinite loop here: https://github.com/funfix/funfix/blob/master/packages/funfix-effect/src/io.ts#L2200.
This is caused by the fact that different lerna packages load different funfix-core module instances and different Try constructors so instanceof doesn't work.

This affects only development stage when packages are linked and can be worked around by using lerna's hoisting feature, so duplicate funfix packages will be moved to top level node_modules folder.

Some ideas to settle this

  1. Use optional check by constructor name, ex:
if (current instanceof Try || (current.constructor && (current.constructor.name === "TSuccess" || current.constructor.name === "TFailure"))) {
  // ...yeah, ugly hack
}
  1. Throw an error in default switch branch here: https://github.com/funfix/funfix/blob/master/packages/funfix-effect/src/io.ts#L2274 with an explanation of the issue, so at least developers know how to workaround it. As CONS - exhaustivity check will be lost for this switch statement :(, may be covered by tests.

  2. Add a warning note in IO's documentation to inform developers about potential issue

Related issue: lerna/lerna#1451 (hosting is not an option for thit guy)

Here https://github.com/lostintime/funfix-lerna-loop is an example repo to reproduce it.

I'm not sure any action should be taken, let's discuss.

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