Closed ghost closed 8 years ago
We would appreciate a self-contained demonstration of the problem that we can use to debug the issue.
@mhegazy That's a very hard thing to do because I ran TS tests with ts-node. Then everything went slow and this message occured. I then installed TS 2.0.3 and everything works just fine. Later on I tested again with latest dev version, and same thing happened. However I suspect there is a 50% 50% fault here. That ts-node isn't updated to handle latest changes in TS dev version, and something wrong in the TS source code itself. For when I was looking at this, it seems to me that ts-node are doing some weird stuff.
At that time i was running a combo with Mocha + TS dev + ts-node. And I was using Mochas watch task. It was only when I used the watch task this happened. If I ran the tests normally it worked just fine. So maybe Mocha - my quessing - Mocha's require flag calling ts-node and ts-node calling TS dev code too many times ( because of the fact I ran out of memory) and then again ts-node isn't compatible with latest dev version, and I got the error shown above.
@zubuzon I am afraid i can not reproduce this with latest version of ts-node and typescript. without having a clear repro steps, or a sample input, this issue is not actionable.
@mhegazy It seems to have been fixed in latest dev version. I just ran the same tests again. So I'm closing this one.
@mhegazy I reopen this as I ran into it again. It seems to happen on different computers now with same setup.
"devDependencies": {
"@types/chai": "^3.4.33",
"@types/mocha": "^2.2.32",
"@types/node": "^6.0.45",
"mocha": "3.1.2",
"chai": "3.5.0",
"tslint": "next",
"ts-node": "1.6.0",
"typescript": "next"
}
And in the tsconfig.js file
{
"compilerOptions": {
"allowJs": false,
"allowUnreachableCode": false,
"forceConsistentCasingInFileNames": true,
"declaration": false,
"experimentalDecorators": true,
"moduleResolution": "node",
"target": "es6",
"lib": ["es7"],
"noEmitHelpers": true,
"newLine": "LF",
"noImplicitAny": true,
"project": "src",
"noLib": false,
"removeComments": false,
"pretty": true,
"strictNullChecks": true,
"stripInternal": true,
"sourceMap": false,
"inlineSourceMap": false,
"suppressImplicitAnyIndexErrors": false,
"outDir": "lib/",
"types": ["mocha", "chai", "node"]
}}
With this setup if you try to run Mocha watch task this happened.
"scripts": {
"build": "tsc -p src",
"test": "mocha test/**/*.ts -R spec --bail",
"watch:tests": "mocha test/**/*.ts -R spec --bail --watch"
},
NodejS version I tried this one is 4 - latest (6.9.1).
Current TS version is latest nightly build.
Here are some ts/node stack traces;
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Module._compile (module.js:570:32)
at Module.m._compile (node_modules\ts-node\src\index.ts:403:23)
at Module._extensions..js (module.js:579:10)
at Object.require.extensions.(anonymous function) [as .ts] (node_modules\ts-node\src\index.ts:406:12)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
@blakeembrey does this sound familiar?
Nope, never seen it. Trying to look through it, but without any way to reproduce I'm kind of stuck.
Edit: I'm ok moving the discussion to ts-node
where I'm also responding now or keeping this open.
@mhegazy I know what's causing this, and it may be an surprise! Look at the latest post in this issue ticket: https://github.com/TypeStrong/ts-node/issues/224#issuecomment-255500697
It's the comment!
This looks like a TS bug then.
I don't know, but I also video recorded it. Should I send the video somewhere? It's clearly that's the comments fault.
@mhegazy So you don't have to click each time, here's the two cases:
Failing:
/**
* Define property
*
* @typedef {any} defineProperty
* @property {[any]} [obj]
* @property {[string]} [prop]
* @property {[val]} [val]
*/
function defineProperty(obj: any, prop: string, val: any): any {
return Object.defineProperty(obj, prop, {
configurable: true,
enumerable: false,
writable: true,
value: val
});
}
export default defineProperty;
Passing:
/**
* Define property
*/
function defineProperty(obj: any, prop: string, val: any): any {
return Object.defineProperty(obj, prop, {
configurable: true,
enumerable: false,
writable: true,
value: val
});
}
export default defineProperty;
I'm going to see if I can reduce this further on the playground.
Edit: it doesn't even repro. I'm going to try the nightly npm release.
I created a repro from the ts-node
issue. See https://github.com/blakeembrey/ts-and-ts-node-compile-bug-224, run npm install
and npm test
.
Edit: I can't reproduce without ts-node
. I can repro without mocha
using node -r ts-node/register test/index.ts
.
Here's a much smaller repro that fails 100% of the time for me. I can only get it reproducing with ts-node
, not the CLI, so I highly suspect it's an issue with the language service. It's running on the latest nightly.
To test the repro, run npm install-test
or ./node_modules/.bin/ts-node --no-cache index.ts
.
Things I noticed:
import "./foo"
does not trigger the bug.@mhegazy @blakeembrey Oh, and this doesn't reproduce in 2.0.3
. It repros in 2.1.0-dev.20161022
, though. That should help you all bisect it.
TypeScript Version: 2.0.3 / nightly (2.1.0-dev.201xxxxx) nightly (2.1.0-dev.20161018) Code ...
Expected behavior: It should work Actual behavior: Not sure what happened here. Was running tests with ts-node, and suddenly everything went very slow before I ran out of memory (I have 64 GB in this computer). A restart of the watch task resulted in this