Tslint: Having multiple versions of typescript causes cryptic errors and eventual heap OOM

Created on 11 Dec 2018  ยท  5Comments  ยท  Source: palantir/tslint

Bug Report

  • __TSLint version__: 5.11.0
  • __TypeScript version__: 2.7.2
  • __Running TSLint via__: CLI

Actual behavior

The 'no-duplicate-variable' rule threw an error in '/home/vsviridov/projects/tessa-front-end/src/brand.ts':
TypeError: Cannot read property 'length' of undefined
    at cb (/home/vsviridov/projects/tessa-front-end/node_modules/tslint/lib/rules/noDuplicateVariableRule.js:81:66)
    at visitNodes (/home/vsviridov/projects/tessa-front-end/node_modules/typescript/lib/typescript.js:13272:30)
    at Object.forEachChild (/home/vsviridov/projects/tessa-front-end/node_modules/typescript/lib/typescript.js:13479:24)
    at NoDuplicateVariableWalker.walk (/home/vsviridov/projects/tessa-front-end/node_modules/tslint/lib/rules/noDuplicateVariableRule.js:88:19)
    at Rule.AbstractRule.applyWithWalker (/home/vsviridov/projects/tessa-front-end/node_modules/tslint/lib/language/rule/abstractRule.js:31:16)
    at Rule.apply (/home/vsviridov/projects/tessa-front-end/node_modules/tslint/lib/rules/noDuplicateVariableRule.js:34:21)
    at Linter.applyRule (/home/vsviridov/projects/tessa-front-end/node_modules/tslint/lib/linter.js:197:29)
    at /home/vsviridov/projects/tessa-front-end/node_modules/tslint/lib/linter.js:139:85
    at Object.flatMap (/home/vsviridov/projects/tessa-front-end/node_modules/tslint/lib/utils.js:151:29)
    at Linter.getAllFailures (/home/vsviridov/projects/tessa-front-end/node_modules/tslint/lib/linter.js:139:32)

and eventually

<--- Last few GCs --->

[26639:0x3ed66f0]     7637 ms: Mark-sweep 824.6 (848.2) -> 824.6 (839.7) MB, 159.5 / 0.0 ms  (average mu = 0.472, current mu = 0.000) last resort GC in old space requested
[26639:0x3ed66f0]     7819 ms: Mark-sweep 824.6 (839.7) -> 824.6 (839.2) MB, 182.6 / 0.0 ms  (average mu = 0.293, current mu = 0.000) last resort GC in old space requested


<--- JS stacktrace --->

==== JS stack trace =========================================

    0: ExitFrame [pc: 0x5a2b215be1d]
Security context: 0x0e1b3cd9e6e1 <JSObject>
    1: _loop_1(aka _loop_1) [0x1758b91e1259] [/home/vsviridov/projects/tessa-front-end/node_modules/tslint/lib/rules/noShadowedVariableRule.js:~277] [pc=0x5a2b2b7ca20](this=0x3ad48c7826f1 <undefined>,identifier=0x2aa7072330b1 <IdentifierOb
ject map = 0x2870d7fcda49>)
    2: /* anonymous */(aka /* anonymous */) [0x1758b91e12b9] [/home/vsviridov/projects/tessa-f...

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
 1: 0x8dbaa0 node::Abort() [node]
 2: 0x8dbaec  [node]
 3: 0xad83de v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [node]
 4: 0xad8614 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [node]
 5: 0xec5c42  [node]
 6: 0xed545f v8::internal::Heap::AllocateRawWithRetryOrFail(int, v8::internal::AllocationSpace, v8::internal::AllocationAlignment) [node]
 7: 0xe9e4b6 v8::internal::Factory::AllocateRawArray(int, v8::internal::PretenureFlag) [node]
 8: 0xe9ed3a v8::internal::Factory::NewFixedArrayWithFiller(v8::internal::Heap::RootListIndex, int, v8::internal::Object*, v8::internal::PretenureFlag) [node]
 9: 0xe9f2f7 v8::internal::Factory::NewUninitializedFixedArray(int, v8::internal::PretenureFlag) [node]
10: 0xe5267f  [node]
11: 0x10f839d v8::internal::Runtime_GrowArrayElements(int, v8::internal::Object**, v8::internal::Isolate*) [node]
12: 0x5a2b215be1d
Aborted (core dumped)

Expected behavior

Should lint correctly.

Reasoning

The reason I assume it's tslib, it's because when I install dependencies with npm it works, but when I install them with yarn it breaks.

I did an strace -e trace=file on the tslint for both kinds of dependencies, and in npm case there's a tslib bundled in the tslint/node_modules folder, but with yarn it uses the main node_modules and those two are different versions (1.9.0 vs 1.9.3)

Accepting PRs Needs Investigation Bug ๐ŸŒน R.I.P. ๐ŸŒน

All 5 comments

Upon further investigation it look like it was not related to tslib but rather some packages was bringing typescript@3 as a dependency. Looks like the code was compiled with one version of typescript, but checked with another, and the constants for node types are mismatched.

Looks like an issue with yarn and rxjs-tslint which my project was depending on.

https://github.com/ReactiveX/rxjs-tslint/issues/59

๐Ÿ’€ _It's time!_ ๐Ÿ’€

TSLint is being deprecated and no longer accepting pull requests for major new changes or features. See #4534. ๐Ÿ˜ฑ

If you'd like to see this change implemented, you have two choices:

  • Recommended: Check if this is available in ESLint + typescript-eslint โœ…
  • _Not Recommended: Fork TSLint locally_ ๐Ÿคทโ€โ™‚๏ธ

๐Ÿ‘‹ It was a pleasure open sourcing with you!

_If you believe this message was posted here in error, please comment so we can re-open the issue!_

๐Ÿค– Beep boop! ๐Ÿ‘‰ TSLint is deprecated ๐Ÿ‘ˆ _(#4534)_ and you should switch to typescript-eslint! ๐Ÿค–

๐Ÿ”’ This issue is being locked to prevent further unnecessary discussions. Thank you! ๐Ÿ‘‹

Was this page helpful?
0 / 5 - 0 ratings