You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
TypeScript version: 2.8.0-dev.20180127 (also applies to v2.4.2 and v2.6.2). WebStorm version: 2017.3.3 (also applies to 2017.3.1). VS Code version: 1.19.3 Search terms: "tsserver heap"
Background:
Accidentally adding MPEG-TS files (which also use the .ts extension) to the project tree causes the TypeScript service in the WebStorm and VS Code IDEs to hang and provide no useful error message.
Directly running tsc v2.8.0-dev.20180127 from the command-line works just fine on the .ts files, as does the webpack v3.10.0 build process (via ts-loader v3.2.0), because they only consume whatever files are explicitly imported, however, IDE TypeScript services hang because they analyse every file in the project tree.
MWE
Simpy add a Transport Stream (.ts) video file under your project tree (eg. Big Buck Bunny – 61.7Mb), ie. into a folder at the project root called vids/. Now open a TypeScript source file in the project in an IDE such as VS Code.
Errors and warnings in TypeScript source should be indicated by syntax highlighting or red underlines in the latest WebStorm IDE and VS Code.
Actual behaviour:
After 1-2 minutes of hanging on startup, each IDE's TypeScript service throws a heap error, and so doesn't get as far as communicating the errors/warnings to the IDE for appropriate syntax highlighting.
I have encountered this error two or three times over the last year (it was present in TypeScript v2.1.5 too), and every time it catches me out, killing a lot of work hours in tracking down the problem again.
MPEG-TS files can alternatively be named .tsv or .tsa, which stops them being consumed as TypeScript files. However, the onus is rather on TypeScript to handle them properly, as MPEG-TS has been using the .ts file extension since at least its release in 1995, well before the TypeScript project.
Proposal:
Determine whether a .ts file is of MPEG-TS type by examining the first few bytes of it. The Wikipedia page indicates that an MPEG-TS file is merely a "sequence of packets, without any global header". Thus, a valid MPEG-TS file will start with a header packet (the format is again described on the Wikipedia page), beginning with a sync byte, invariably with the value 0x47 (The character 'G'). If there is a chance that this could clash with a valid TypeScript file, then further bytes should be read in.
Implement a default, yet overridable, file size limit for .ts files to prevent the TypeScript compiler spending too long hanging on them (the existing --disableSizeLimit is for JS only as far as I understand). This would handle the case of invalid MPEG-TS files (not really a big concern, though) or other unforeseen file extension clashes with .ts.
Provide a better error message.
The text was updated successfully, but these errors were encountered:
Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed.
TypeScript version: 2.8.0-dev.20180127 (also applies to v2.4.2 and v2.6.2).
WebStorm version: 2017.3.3 (also applies to 2017.3.1).
VS Code version: 1.19.3
Search terms: "tsserver heap"
Background:
.ts
extension) to the project tree causes the TypeScript service in the WebStorm and VS Code IDEs to hang and provide no useful error message.tsc
v2.8.0-dev.20180127 from the command-line works just fine on the.ts
files, as does the webpack v3.10.0 build process (viats-loader
v3.2.0), because they only consume whatever files are explicitly imported, however, IDE TypeScript services hang because they analyse every file in the project tree.MWE
Simpy add a Transport Stream (.ts) video file under your project tree (eg. Big Buck Bunny – 61.7Mb), ie. into a folder at the project root called
vids/
. Now open a TypeScript source file in the project in an IDE such as VS Code.Config
Sample
tsconfig.json
(exact values unimportant;tsc --init
likely suffices):Expected behaviour:
Errors and warnings in TypeScript source should be indicated by syntax highlighting or red underlines in the latest WebStorm IDE and VS Code.
Actual behaviour:
After 1-2 minutes of hanging on startup, each IDE's TypeScript service throws a heap error, and so doesn't get as far as communicating the errors/warnings to the IDE for appropriate syntax highlighting.
WEBSTORM
Log:
VS CODE
Symptoms:
[TypeScript Importer]: initializing
for about 1-2 minutes.Log:
Related issues:
I have encountered this error two or three times over the last year (it was present in TypeScript v2.1.5 too), and every time it catches me out, killing a lot of work hours in tracking down the problem again.
#12804 (comment)
Workaround:
MPEG-TS files can alternatively be named
.tsv
or.tsa
, which stops them being consumed as TypeScript files. However, the onus is rather on TypeScript to handle them properly, as MPEG-TS has been using the.ts
file extension since at least its release in 1995, well before the TypeScript project.Proposal:
.ts
file is of MPEG-TS type by examining the first few bytes of it. The Wikipedia page indicates that an MPEG-TS file is merely a "sequence of packets, without any global header". Thus, a valid MPEG-TS file will start with a header packet (the format is again described on the Wikipedia page), beginning with a sync byte, invariably with the value0x47
(The character 'G'). If there is a chance that this could clash with a valid TypeScript file, then further bytes should be read in..ts
files to prevent the TypeScript compiler spending too long hanging on them (the existing--disableSizeLimit
is for JS only as far as I understand). This would handle the case of invalid MPEG-TS files (not really a big concern, though) or other unforeseen file extension clashes with.ts
.The text was updated successfully, but these errors were encountered: