Flow: Slow Merging Inference

Created on 23 Mar 2016  路  11Comments  路  Source: facebook/flow

It seems that my code is doing somethings weird for Flow, it used to work fine, but all the sudden it takes a long time (more than 10 minutes) to do the merging inference pass.

Launching Flow server for /Users/Emiliano/Source/parser
Spawned flow server (child pid=77755)
Logs will go to /private/tmp/flow/zSUserszSEmilianozSSourcezSparser.log
flow is still initializing; this can take some time. [merging inference] \

I could not find a way to verbose Flow, or to trace its execution to see what is going on. Does such option exists? How can I diagnose or see what it is doing that is taking so long?

nontermination / perf

Most helpful comment

I also got this error, turns out i have some module that depends recursively:

  • module A requires module B
  • module B requires module A

Fixed it by stopping the module to require each other

All 11 comments

I also got this error, turns out i have some module that depends recursively:

  • module A requires module B
  • module B requires module A

Fixed it by stopping the module to require each other

@arypurnomoz how did you trace which module had cyclic dependency?

I was using flow well till the latest release, and it never come out of flow is still initializing untill my system frozen few times :-) mac OSX 10.9.5.

i just removed all require, started flow, then i added the required module one by one to see which one froze my flow server.

@arypurnomoz thanks. My issue was tons of dependencies in node_modeules. I excluded them, and added interface def for some of them I use.

@bsr203 I made a tool specifically to help with this :)

https://github.com/AndrewRayCode/webpack-cyclic-dependency-checker

In my case I got a weird code a bit like this:

const newThing = [
  ...something,
  ...Object.keys(obj).map((key) => return func(/* return an object */))
]

Had to change to

const stuff = Object.keys(obj).map((key) => return func(/* return an object */))
const newThing = [
  ...something,
  ...stuff
]

to avoid the 5min stuck on "merging inference".

Was not fun to debug but I did some dichotomie using flow [ignore] option to disable files and find the culprit. Then I disabled code in the file that was slowing down...

Also I was doing "killall flow && flow" to be sure to have a new instance cause otherwise, I was not always able to get the slow "merging inference" step.

I've had simple changes make flows inference process skyrocket a few times now. The lack of tools to diagnose this makes flow almost intolerable for me to use. Always worried I'll make it go crazy and be stuck in a lengthy process of trial and error.

Has there been any progress on making Flow not throw it's hands up in anger when it runs into a circular dependency? I have two files that import each other to use constants, but Flow takes an eternity on the "merging inference" step.

I had the same problem. It was on a very new project (a few files all under 20-30 lines long). Initialized flow and it was doing this for over 20 minutes until I cancelled it.

@arypurnomoz It works! Thanks!

Is this still relevant?

Was this page helpful?
0 / 5 - 0 ratings