TypeScript: Typescript service is often stopping working randomly: Cannot read property 'charCount' of undefined

From @asvetliakov on June 12, 2017 16:40

  • VSCode Version: 1.13.0
  • OS Version: macOS 10.12.5

May be related to #28112

I’m not sure how to reproduce it yet. It seems to happen randomly and VERY often. Steps:

  1. Edit your code (medium to large project)
  2. After some time the ts service stops working: 2.1. The validation messages are incorrect and have incorrect location 2.2. Completion and navigation features stops working

Typescript version: 2.3.3, also i didn’t have any issues with vscode 1.12.0

I’m getting this in typescript service output:

[Error  - 6:32:24 PM] 'navtree' request failed with error.
Error processing request. Cannot read property 'charCount' of undefined
TypeError: Cannot read property 'charCount' of undefined
    at LineNode.walk (/Users/asvetl/work/applications/frontend/node_modules/typescript/lib/tsserver.js:78490:47)
    at LineIndex.edit (/Users/asvetl/work/applications/frontend/node_modules/typescript/lib/tsserver.js:78358:35)
    at ScriptVersionCache.getSnapshot (/Users/asvetl/work/applications/frontend/node_modules/typescript/lib/tsserver.js:78150:47)
    at TextStorage.getSnapshot (/Users/asvetl/work/applications/frontend/node_modules/typescript/lib/tsserver.js:73269:32)
    at ScriptInfo.getSnapshot (/Users/asvetl/work/applications/frontend/node_modules/typescript/lib/tsserver.js:73378:41)
    at LSHost.getScriptSnapshot (/Users/asvetl/work/applications/frontend/node_modules/typescript/lib/tsserver.js:73648:39)
    at SyntaxTreeCache.getCurrentSourceFile (/Users/asvetl/work/applications/frontend/node_modules/typescript/lib/tsserver.js:71449:44)
    at Object.getNavigationTree (/Users/asvetl/work/applications/frontend/node_modules/typescript/lib/tsserver.js:71953:71)
    at IOSession.Session.getNavigationTree (/Users/asvetl/work/applications/frontend/node_modules/typescript/lib/tsserver.js:77613:62)
    at Session.handlers.ts.createMapFromTemplate._a.(anonymous function) (/Users/asvetl/work/applications/frontend/node_modules/typescript/lib/tsserver.js:76670:61)

Full log: https://pastebin.com/X6xpSR1z

Thanks

Copied from original issue: Microsoft/vscode#28543

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 1
  • Comments: 19 (2 by maintainers)

Commits related to this issue

Most upvoted comments

I am not sure if my problem is exactly the same, but after having added some new files in the project, tsc began to crash with :

C:\node-projects\payroll-app\node_modules\schemats\node_modules\tslint\node_modules\typescript\lib\tsc.js:2062
            throw e;
            ^

Error: Debug Failure. False expression.
    at computePositionOfLineAndCharacter (C:\node-projects\payroll-app\node_modules\schemats\node_modules\tslint\node_modules\typescript\lib\tsc.js:3752:22)
    at Object.getPositionOfLineAndCharacter (C:\node-projects\payroll-app\node_modules\schemats\node_modules\tslint\node_modules\typescript\lib\tsc.js:3742:16)
    at Object.formatDiagnosticsWithColorAndContext (C:\node-projects\payroll-app\node_modules\schemats\node_modules\tslint\node_modules\typescript\lib\tsc.js:55564:59)
    at reportDiagnosticWithColorAndContext (C:\node-projects\payroll-app\node_modules\schemats\node_modules\tslint\node_modules\typescript\lib\tsc.js:58760:25)
    at reportDiagnostic (C:\node-projects\payroll-app\node_modules\schemats\node_modules\tslint\node_modules\typescript\lib\tsc.js:58722:9)
    at reportDiagnostics (C:\node-projects\payroll-app\node_modules\schemats\node_modules\tslint\node_modules\typescript\lib\tsc.js:58727:13)
    at compileProgram (C:\node-projects\payroll-app\node_modules\schemats\node_modules\tslint\node_modules\typescript\lib\tsc.js:59088:13)
    at compile (C:\node-projects\payroll-app\node_modules\schemats\node_modules\tslint\node_modules\typescript\lib\tsc.js:59040:26)
    at performCompilation (C:\node-projects\payroll-app\node_modules\schemats\node_modules\tslint\node_modules\typescript\lib\tsc.js:58929:33)
    at Object.executeCommandLine (C:\node-projects\payroll-app\node_modules\schemats\node_modules\tslint\node_modules\typescript\lib\tsc.js:58872:9)
    at Object.<anonymous> (C:\node-projects\payroll-app\node_modules\schemats\node_modules\tslint\node_modules\typescript\lib\tsc.js:59230:4)
    at Module._compile (module.js:573:30)
    at Object.Module._extensions..js (module.js:584:10)
    at Module.load (module.js:507:32)
    at tryModuleLoad (module.js:470:12)
    at Function.Module._load (module.js:462:3)
    at Module.require (module.js:517:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (C:\node-projects\payroll-app\node_modules\schemats\node_modules\tslint\node_modules\typescript\bin\tsc:2:1)
    at Module._compile (module.js:573:30)
    at Object.Module._extensions..js (module.js:584:10)
    at Module.load (module.js:507:32)
    at tryModuleLoad (module.js:470:12)
    at Function.Module._load (module.js:462:3)
    at Function.Module.runMain (module.js:609:10)
    at startup (bootstrap_node.js:158:16)
    at bootstrap_node.js:598:3

Tsc : 2.5.1 and 2.6.0-dev.20170829 Windows 10 64 bits Nodejs 8.4.0

I can provide ts server log if need be.

I haven’t seen the issue any more after upgrading to 2.5.2