Skip to content

Language-service-plugin can cause 'scriptInfo for file ... missing' assertion in tsserver #15344

@egamma

Description

@egamma

// CC @mjbvz

The tslint-language-service plugin runs tslint as a language service extension. This works nicely for simple tslint rules, but for rules that require the typechecker the tsserver ends up hanging with a 'scriptInfo for file ... lib/lib.d.ts' is missing assertion.

This could be an issue in tslint (the rules that use the type checker work fine on the command line) or this can be an issue in the tsserver.

Here are the steps to reproduce (update: does not repro on Linux, repos on Windows):

  • enable debugging of the tsserver so that we can attach a debugger later set TSS_DEBUG=5859
  • enable tracing set TSS_LOG=-level verbose -file c:\tmp\tsserver.log
  • git clone https://github.com/egamma/test-ts-server-plugin.git
  • cd test-ts-server-plugin
  • npm install (installs tslint, ts-language-service plugin, and the TS insider version)
  • code-insiders .
  • switch to the workspace version of TS using the version switcher in the bottom right corner
  • open hello.ts, there is a tslint warning with a quick fix and all is good, you can make edits in the file
    image
  • open tslint.json and uncomment the no-unused-variable rule on line 6. Since tslint 5 this rule requires the TS type checker, see the breaking changes section in the tslint release notes.
  • save and restart code-insiders or run reload window
  • open hello.ts
  • you will still see tslint warning
  • change the contents of hello.ts to trigger a syntax check ->the tsserver is now no longer responding to requests, e.g. no more hovers. You can also verify this by inspecting the trace in c:\tmp\tsserver.log.

Debugging

To debug the current server state you can attach the debugger from another VS Code version. In this setup I describe using the vscode stable version.

  • open code (the stable version) on an empty workspace.
  • create the following launch configuration
{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "node",
            "request": "attach",
            "name": "Attach to TS Server",
            "port": 5859,
            "sourceMaps": true,
            "protocol": "legacy",
			"outFiles": [
				"${workspaceRoot}/out/**/*.js"
			]
        }
    ]
}
  • attach the debugger and you will notice that the tsserver stopped in qn assertion failure script info is missing on a debugger statement:
    image

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptVS Code TrackedThere is a VS Code equivalent to this issue

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions