Skip to content
This repository has been archived by the owner on Jun 1, 2024. It is now read-only.

Infinite loop in lerna project setup #144

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

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 subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants