Skip to content

Truncate lineText in references responses to avoid RangeError #50134

@amcasey

Description

@amcasey

Repro

Present in 4.7.4. and main.

  1. git clone https://github.com/apache/echarts
  2. cd echarts
  3. git reset --hard c58437740899254aeb318595d4e5e324ad48961d
  4. cd ..
  5. npm install @typescript/server-replay
  6. Download replay.txt
  7. npx tsreplay ./echarts path/to/replay.txt path/to/tsserver.js
replay.txt
{"rootDirPlaceholder":"@PROJECT_ROOT@","serverArgs":["--disableAutomaticTypingAcquisition"]}
{"seq":1,"type":"request","command":"configure","arguments":{"preferences":{"includePackageJsonAutoImports":"off"},"watchOptions":{"excludeDirectories":["**/node_modules"]}}}
{"seq":2,"type":"request","command":"updateOpen","arguments":{"changedFiles":[],"closedFiles":[],"openFiles":[{"file":"@PROJECT_ROOT@/dist/echarts.common.min.js","projectRootPath":"@PROJECT_ROOT@"}]}}
{"seq":3,"type":"request","command":"references","arguments":{"file":"@PROJECT_ROOT@/dist/echarts.common.min.js","line":45,"offset":362884}}
RangeError: Invalid string length
    at JSON.stringify (<anonymous>)
    at formatMessage (typescript/built/local/tsserver.js:174550:29)
    at IOSession.Session.writeMessage (typescript/built/local/tsserver.js:175529:31)
    at IOSession.Session.send (typescript/built/local/tsserver.js:175526:22)
    at IOSession.Session.doOutput (typescript/built/local/tsserver.js:175579:22)
    at IOSession.Session.onMessage (typescript/built/local/tsserver.js:177220:30)

One (of several?) problematic reference is at line 45, offsets 280-284 of echarts/dist/echarts.common.min.js.

A nice solution would truncate before and after a range containing the offset of interest. A minimal solution would truncate from the end, possibly cutting off the actual reference.

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptFix AvailableA PR has been opened for this issue

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions