lostintime / funfix-lerna-loop

Reproducing infinite loop issue with funfix in lerna project setup

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Funfix Infinite Loop with lerna

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)

Installation

Clone this repo then run npm install.

To reproduce the issue run

npm run start

and this shoud never finish execution.

About

Reproducing infinite loop issue with funfix in lerna project setup


Languages

Language:TypeScript 100.0%