Repository navigation
Description
TypeScript Version: 2.3.3 AND 2.3.4.
I am trying to create a definition file for promise-throttle, it has the following API:
var PromiseThrottle = require('promise-throttle');
var promiseThrottle = new PromiseThrottle({});
...Here is the setup:
src/test.ts
import PromiseThrottle from 'promise-throttle';
...types/promise-throttle/index.d.ts
interface PromiseThrottleOptions {
requestsPerSecond: number;
promiseImplementation?: any;
}
export default class PromiseThrottle {
constructor(options: PromiseThrottleOptions);
add<T>(promise: () => Promise<T>): Promise<T>;
addAll<T>(promises: ReadonlyArray<() => Promise<T>>): Promise<T>;
dequeue(): void;
}tsconfig.json
{
"compilerOptions": {
"module": "commonjs",
"target": "es2016",
"outDir": "dist",
"baseUrl": "./",
"paths": {
"*": ["types/*/index.d.ts"]
},
"alwaysStrict": true,
"forceConsistentCasingInFileNames": true,
"noFallthroughCasesInSwitch": true,
"noImplicitAny": false,
"noImplicitReturns": true,
"noImplicitThis": true,
"noUnusedParameters": false,
"noUnusedLocals": true,
"skipLibCheck": false,
"sourceMap": true,
"strictNullChecks": true,
"allowSyntheticDefaultImports": true
},
"include": [
"src/**/*.ts"
]
}Expected behavior:
TSC to compile the code fine.
Actual behavior:
FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory npm ERR! Windows_NT 10.0.15063 npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "build" npm ERR! node v7.10.0 npm ERR! npm v4.2.0 npm ERR! code ELIFECYCLE npm ERR! errno 3 npm ERR! <>@1.0.0 build:tscnpm ERR! Exit status 3 npm ERR! npm ERR! Failed at the <>@1.0.0 build script 'tsc'. npm ERR! Make sure you have the latest version of node.js and npm installed. npm ERR! If you do, this is most likely a problem with the <> package, npm ERR! not with npm itself. npm ERR! Tell the author that this fails on your system: npm ERR! tsc npm ERR! You can get information on how to open an issue for this project with: npm ERR! npm bugs <> npm ERR! Or if that isn't available, you can get their info via: npm ERR! npm owner ls <> npm ERR! There is likely additional logging output above. npm ERR! Please include the following file with any support request: npm ERR! %AppData%\Roaming\npm-cache\_logs\2017-05-31T08_01_13_818Z-debug.log
Seems to be similar to this issue?
Activity
JoshuaKGoldberg commentedon Jun 27, 2017
I'm also able to repro this when using
tsc --watch --prettyon a very large project (~700 files, including extremely large .d.ts references). It takes a few dozen incremental compilations, then this error.sandersn commentedon Jun 29, 2017
This doesn't repro in master any more, so I think it's fixed. I'm going to make the repro a little smaller because I'm curious what's causing it. It's not the parse errors!
Josh Ghoulberg 👻 (@JoshuaKGoldberg) your issue is very likely different since (1) it involves a large project, not a tiny one with parse errors (2) it involves
--watchwith incremental compilations. Can you create a separate issue if you are able to reduce the size of your repro, or even make the crash reproduce deterministically?sandersn commentedon Jun 29, 2017
Here's the smallest repro I have so far:
{ "compilerOptions": { "strictNullChecks": true } }It looks like there was an infinite recursion when checking assignability of arrays with strictNullChecks on. It could also be that the faster overload comparison in 2.4 gets through all the array overloads without hitting an exponential condition that leads to out of memory.
sandersn commentedon Jun 29, 2017
Oops, I just realised that all my investigation should have gone to #16234! I'll look at this bug next, but it shouldn't be closed yet.
sandersn commentedon Jun 29, 2017
Sean Sobey (@SeanSobey) I can't get this to repro with 2.3.4 or master. The only difference is that I used
tscdirectly instead of an npm command. What does your package.json look like? Is there anything innode_modulesthat might cause the problem?(I also added some simple code that uses
PromiseThrottleto get rid of the unused-local-identifiers error, but that didn't change anything.)SeanSobey commentedon Jun 30, 2017
Nathan Shively-Sanders (@sandersn) Yes your are correct my example does not actually repo the issue, apologies it turns out there was a bit missing, here is the full setup that replicates the behavior (at least for me, Windows 10 64bit):
package.json{ "name": "test", "version": "1.0.0", "private": true, "main": "dist/test.js", "scripts": { "build": "tsc" }, "dependencies": { "typescript": "2.3.4" } }tsconfig.json{ "compilerOptions": { "module": "commonjs", "target": "es2016", "outDir": "dist", "baseUrl": "./", "paths": { "*": ["types/*/index.d.ts"] }, "alwaysStrict": true, "forceConsistentCasingInFileNames": true, "noFallthroughCasesInSwitch": true, "noImplicitAny": false, "noImplicitReturns": true, "noImplicitThis": true, "noUnusedParameters": false, "noUnusedLocals": true, "skipLibCheck": false, "sourceMap": true, "strictNullChecks": true, "allowSyntheticDefaultImports": true }, "include": [ "src/**/*.ts" ] }types\promise-throttle\index.d.tssrc\test.tsYou can then run:
npm run build, which is what I did, not sure if running tsc direct has the same behaviour,It turns out to be that
getManymethod onTest, specifically therequests.map, removing that will then compile fine (with the expected syntax errors). I not sure why and I am aware that it is not valid TS but it reproduces the memory issue with TSC.sandersn commentedon Jun 30, 2017
Thanks, that does indeed repro for me. Fortunately, it no longer repros on master. Can you try
typescript@nextto see if that fixes the crash?SeanSobey commentedon Jul 3, 2017
Nathan Shively-Sanders (@sandersn) Yes, looks like TS 2.4.0 and @ next (2.5.0-dev.20170629) both have resolve the issue. Thanks!