-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Compilation hangs when using Bluebird promise library #17716
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
Comments
This problem may be related with Another option may be related with BlueBird type definition: Progress
|
I just stumbled upon the same problem. Using |
I have found a more simpler way to reproduce the bug. Here's the debug repository https://github.com/manojkhannakm/typescript-bluebird-debug. The repository has two modules
When running
All I can think of is that the compiler is stuck in a loop in finding the definition for On removing Also I found that publishing |
@manojkhannakm can you give more detail on your repro? I tried Here's my modified tsconfig. I'm not sure path mapping is the right thing to represent a local dependency from npm. And I had to remove rootDir to get compilation to succeed as well. {
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"baseUrl": ".",
"paths": {
"module-a": ["../module-a/src"]
},
"outDir": "./dist",
"strict": true,
"declaration": true,
"sourceMap": true
}
} |
@wtrocki I can't repro the crash with your example either. Note that I changed the first line of |
@sandersn I think you missed running Also I just tried again with your tsconfig but the compilation still timeouts on Edit: Got this after about 5mins.
|
Thanks, that did it @manojkhannakm |
@manojkhannakm's repro compiles in less than a second with |
@sandersn I just tried debugging from the scratch again but unfortunately the compilation still timeouts. These are the exact steps I followed.
|
On replacing
It should be...
I found out that its because of the tsconfig's
and tried again, the compilation hangs as usual. |
I just found something interesting now, after compiling module-a if I remove the line |
Yes, with your tsconfig the project does indeed run out of memory. The problem is that two copies of Bluebird get referenced, one by module-a and one by module-b. The compiler is supposed to be smart enough to dedupe them if they have the same package version. I'm not sure why that doesn't happen here. @Andy-MS has done some work over the last few releases on deduping. Andy, can you take a look? After the deduping fails, because Typescript is structural, it should be able to relate the two Bluebird copies structurally. But the structure of Bluebird causes the compiler to run out of memory when comparing Bluebird to itself. I haven't found out why yet. I have the failure under the debugger, so I'll update if I find out. |
I haven't found a specific problem besides "Bluebird is very big and recursive", but I made a fix that gets compile time down to 2.9 seconds. This is still considerably slower than the 1 second with `--noStrictGenericChecks". I extended the type reference caching improvement to decompose array type arguments. In other words, previously the type reference caching would treat the relation of This technique, in fact, generalises to any type reference that is a type argument of a type reference. I'm going to try expanding type references recursively when creating a cache key. The cache keys may get too long, but I think it will be instructive either way. |
@wtrocki @manojkhannakm A couple of recent fixes (one of which is described above) should have fixed this. Can you try our your repros with |
@sandersn Its working fine now using typescript@next. Thank you. |
Introduction
Passing bluebird promise from top level application to separate node.js module causing typescript compiler to hang until it gets out of memory. Problem is happening with multiple typescript compiler versions.
Using promises within the same npm module do not cause any of this problems.
** Environment **
TypeScript Version: Version 2.4.1
Latest bluebird library:
@types/bluebird
: "^3.5.5",bluebird
: "^3.5.0",Code
Simplified example:
Expected behavior:
Code should compile.
Actual behavior:
Compilation process hangs with extensive memory and processor usage.
The text was updated successfully, but these errors were encountered: