question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TS language service keeps crashing

See original GitHub issue

Issue Type: Bug

Not at all sure why this happens. One of the stack traces goes like this:

[2022-04-07 17:58:57.661] [exthost] [error] Error: <semantic> TypeScript Server Error (4.6.3)
BADCLIENT: Bad error code, 7027 not found in range 1586..1595 (found: false, false, false, false); could have caused this error:
Debug Failure. Token and statement should start at the same point. {"statementKind":"ReturnStatement","tokenKind":"AsKeyword","errorCode":7027,"start":1586,"length":9}
Error: BADCLIENT: Bad error code, 7027 not found in range 1586..1595 (found: false, false, false, false); could have caused this error:
Debug Failure. Token and statement should start at the same point. {"statementKind":"ReturnStatement","tokenKind":"AsKeyword","errorCode":7027,"start":1586,"length":9}
    at doChange (/vscode/vscode-server/bin/linux-x64/e18005f0f1b33c29e81d732535d8c0e47cafb0b5/extensions/node_modules/typescript/lib/tsserver.js:152864:26)
    at /vscode/vscode-server/bin/linux-x64/e18005f0f1b33c29e81d732535d8c0e47cafb0b5/extensions/node_modules/typescript/lib/tsserver.js:152847:96
    at Function.ChangeTracker.with (/vscode/vscode-server/bin/linux-x64/e18005f0f1b33c29e81d732535d8c0e47cafb0b5/extensions/node_modules/typescript/lib/tsserver.js:145719:17)
    at Object.getCodeActions (/vscode/vscode-server/bin/linux-x64/e18005f0f1b33c29e81d732535d8c0e47cafb0b5/extensions/node_modules/typescript/lib/tsserver.js:152847:64)
    at /vscode/vscode-server/bin/linux-x64/e18005f0f1b33c29e81d732535d8c0e47cafb0b5/extensions/node_modules/typescript/lib/tsserver.js:146964:77
    at Object.flatMap (/vscode/vscode-server/bin/linux-x64/e18005f0f1b33c29e81d732535d8c0e47cafb0b5/extensions/node_modules/typescript/lib/tsserver.js:508:25)
    at Object.getFixes (/vscode/vscode-server/bin/linux-x64/e18005f0f1b33c29e81d732535d8c0e47cafb0b5/extensions/node_modules/typescript/lib/tsserver.js:146964:23)
    at /vscode/vscode-server/bin/linux-x64/e18005f0f1b33c29e81d732535d8c0e47cafb0b5/extensions/node_modules/typescript/lib/tsserver.js:162191:35
    at Object.flatMap (/vscode/vscode-server/bin/linux-x64/e18005f0f1b33c29e81d732535d8c0e47cafb0b5/extensions/node_modules/typescript/lib/tsserver.js:508:25)
    at Object.getCodeFixesAtPosition (/vscode/vscode-server/bin/linux-x64/e18005f0f1b33c29e81d732535d8c0e47cafb0b5/extensions/node_modules/typescript/lib/tsserver.js:162189:23)
    at IpcIOSession.Session.getCodeFixes (/vscode/vscode-server/bin/linux-x64/e18005f0f1b33c29e81d732535d8c0e47cafb0b5/extensions/node_modules/typescript/lib/tsserver.js:173756:64)
    at Session.handlers.ts.Map.ts.getEntries._a.<computed> (/vscode/vscode-server/bin/linux-x64/e18005f0f1b33c29e81d732535d8c0e47cafb0b5/extensions/node_modules/typescript/lib/tsserver.js:172389:61)
    at /vscode/vscode-server/bin/linux-x64/e18005f0f1b33c29e81d732535d8c0e47cafb0b5/extensions/node_modules/typescript/lib/tsserver.js:174069:88
    at IpcIOSession.Session.executeWithRequestId (/vscode/vscode-server/bin/linux-x64/e18005f0f1b33c29e81d732535d8c0e47cafb0b5/extensions/node_modules/typescript/lib/tsserver.js:174060:28)
    at IpcIOSession.Session.executeCommand (/vscode/vscode-server/bin/linux-x64/e18005f0f1b33c29e81d732535d8c0e47cafb0b5/extensions/node_modules/typescript/lib/tsserver.js:174069:33)
    at IpcIOSession.Session.onMessage (/vscode/vscode-server/bin/linux-x64/e18005f0f1b33c29e81d732535d8c0e47cafb0b5/extensions/node_modules/typescript/lib/tsserver.js:174095:35)
    at process.<anonymous> (/vscode/vscode-server/bin/linux-x64/e18005f0f1b33c29e81d732535d8c0e47cafb0b5/extensions/node_modules/typescript/lib/tsserver.js:176730:31)
    at process.emit (node:events:390:28)
    at emit (node:internal/child_process:917:12)
    at processTicksAndRejections (node:internal/process/task_queues:84:21)
	at Function.create (/vscode/vscode-server/bin/linux-x64/e18005f0f1b33c29e81d732535d8c0e47cafb0b5/extensions/typescript-language-features/dist/extension.js:1:502930)
	at dispatchResponse (/vscode/vscode-server/bin/linux-x64/e18005f0f1b33c29e81d732535d8c0e47cafb0b5/extensions/typescript-language-features/dist/extension.js:1:496778)
	at dispatchMessage (/vscode/vscode-server/bin/linux-x64/e18005f0f1b33c29e81d732535d8c0e47cafb0b5/extensions/typescript-language-features/dist/extension.js:1:495646)
	at ChildProcess.<anonymous> (/vscode/vscode-server/bin/linux-x64/e18005f0f1b33c29e81d732535d8c0e47cafb0b5/extensions/typescript-language-features/dist/extension.js:1:495131)
	at ChildProcess.emit (node:events:390:28)
	at emit (node:internal/child_process:917:12)
	at processTicksAndRejections (node:internal/process/task_queues:84:21)

VS Code version: Code 1.66.0 (e18005f0f1b33c29e81d732535d8c0e47cafb0b5, 2022-03-30T05:50:04.419Z) OS version: Darwin x64 20.6.0 Restricted Mode: No Remote OS version: Linux x64 5.10.76-linuxkit

System Info
Item Value
CPUs Intel® Core™ i7-8750H CPU @ 2.20GHz (12 x 2200)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
metal: disabled_off
multiple_raster_threads: enabled_on
oop_rasterization: enabled
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_renderer: enabled_on
video_decode: enabled
video_encode: enabled
webgl: enabled
webgl2: enabled
Load (avg) 6, 6, 5
Memory (System) 16.00GB (0.22GB free)
Process Argv –crash-reporter-id 961ba054-15e1-4479-bbbb-27dee222b72d
Screen Reader no
VM 0%
Item Value
Remote Dev Container: Node.js
OS Linux x64 5.10.76-linuxkit
CPUs Intel® Core™ i7-8750H CPU @ 2.20GHz (6 x 2200)
Memory (System) 3.84GB (0.40GB free)
VM 0%
Extensions (9)
Extension Author (truncated) Version
ndjson-colorizer bus 1.0.0
jupyter-keymap ms- 1.0.0
remote-containers ms- 0.231.5
remote-ssh ms- 0.78.0
remote-ssh-edit ms- 0.80.0
debugger-for-chrome msj 4.13.0
vscode-eslint dba 2.2.2
go gol 0.32.0
vscode-docker ms- 1.21.0
A/B Experiments
vsliv368cf:30146710
vsreu685:30147344
python383:30185418
vspor879:30202332
vspor708:30202333
vspor363:30204092
vswsl492cf:30256860
pythonvspyl392:30443607
pythontb:30283811
pythonptprofiler:30281270
vshan820:30294714
vstes263cf:30335440
vscorecescf:30445987
pythondataviewer:30285071
vscod805cf:30301675
pythonvspyt200:30340761
binariesv615:30325510
bridge0708:30335490
bridge0723:30353136
vsaa593cf:30376535
vsc1dst:30438360
pythonvs932:30410667
wslgetstarted:30449410
pythonvsnew555:30457759
vscscmwlcmt:30465135
vscaat:30438848
pynewfile477:30463512

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
DanielRosenwassercommented, Dec 19, 2022

Thank you @rhefner - here’s a minimal repro based on that.

here’s a repro:

// bar.ts
import * as foo from './foo'
export as namespace foo
export = foo;

declare global {
    const foo: typeof foo;
}
// foo.d.ts
interface Root {
    /**
     * A .default property for ES6 default import compatibility
     */
    default: Root;
}

declare const root: Root;
export = root;
0reactions
rhefnercommented, Jun 24, 2022

Cannot read properties of undefined (reading ‘flags’)

This is also happening to me … At least in my case, seems related to #40991 as commenting out esModuleInterop from my tsconfig.json stops the crashing and re-enabling it reintroduces the crashes. Happens with all extensions disabled, no .vscode/ files in the repo and also happens on VSCode Insiders. Using a PNPM monorepo w/typescirpt@4.7.3, but also tried with typescript@next (4.8.0-dev.20220624) with the same result.

Here’s a copy of the tsserver.log with the private stuff redacted: https://gist.github.com/rhefner/5ad0aa5225d9e56ad2e436c0eb885a83

UPDATE

My issue seems to be caused by one of my ambient type files (loglevel.d.ts) - Commenting out export = log stops the crashes, but also do a few other modifications.

import * as log from 'loglevel'
export as namespace log
export = log // Commenting this out stops the crashes in my case

declare global {
  const log: typeof log
}

…Not sure why that’s crashing tsserver, as it seems that’s it’s allowed - I’m probably missing something very trivial. 😅 Anyways, changing it around to this seems to fix the crashes for me:

declare global {
  const log: typeof import('loglevel')
}

export {}
Read more comments on GitHub >

github_iconTop Results From Across the Web

TS language service keeps crashing · Issue #48701 - GitHub
My issue seems to be caused by one of my ambient type files ( loglevel.d.ts ) - Commenting out export = log stops...
Read more >
VSCode - TypeScript language service died unexpectedly 5 ...
Disabling the "JavaScript and TypeScript Nightly" extension worked for me. The error always said that the workspace was using an old verison of...
Read more >
The JavaScript and TypeScript language service has been ...
The JavaScript and TypeScript language service has been disabled after crashing repeatedly. You may see reduced IntelliSense support for your project.
Read more >
Angular Language Service
ts files. Eclipse IDElink. Either directly install the "Eclipse IDE for Web and JavaScript developers" package which comes with the Angular Language Server ......
Read more >
Vscode language server crashing - Julia Discourse
TMScopeRegistry.ts:47 Overwriting grammar scope name to file mapping ... at vscode-file://vscode-app/c:/Users/steve/AppData/Local/Programs/ ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found