Skip to content

tsgo panics when editing a CSS file #40

Description

@mybearworld

Reproduction steps:

  • Install tsgo (I'm on version Version 7.0.0-dev.20260327.2).
  • Install this extension.
  • In settings.json:
    "languages": {
      "TypeScript": {
        "language_servers": ["tsgo"],
      },
    },
  • Create a TypeScript file to start the LSP.
  • Create a CSS file, write something into it (just a single character like e will do), and save it.
  • Watch the LSP crash (for example by trying to edit the TypeScript file and seeing no autocomplete).

This doesn't happen for Python or JSON files, nor do CSS files seem to have any effect in VSCode, which is why I'm filing this here.

Logs from tsgo:

Resolved client capabilities: {
	"workspace": {
		"applyEdit": true,
		"workspaceEdit": {
			"documentChanges": true,
			"resourceOperations": [
				"create",
				"rename",
				"delete"
			],
			"snippetEditSupport": true
		},
		"didChangeConfiguration": {
			"dynamicRegistration": true
		},
		"didChangeWatchedFiles": {
			"dynamicRegistration": true,
			"relativePatternSupport": true
		},
		"symbol": {
			"dynamicRegistration": true
		},
		"executeCommand": {
			"dynamicRegistration": true
		},
		"workspaceFolders": true,
		"configuration": true,
		"semanticTokens": {
			"refreshSupport": true
		},
		"codeLens": {
			"refreshSupport": true
		},
		"fileOperations": {
			"dynamicRegistration": true,
			"didRename": true,
			"willRename": true
		},
		"inlayHint": {
			"refreshSupport": true
		},
		"diagnostics": {
			"refreshSupport": true
		}
	},
	"textDocument": {
		"synchronization": {
			"dynamicRegistration": true,
			"didSave": true
		},
		"completion": {
			"dynamicRegistration": true,
			"completionItem": {
				"snippetSupport": true,
				"documentationFormat": [
					"markdown",
					"plaintext"
				],
				"deprecatedSupport": true,
				"tagSupport": {
					"valueSet": [
						1
					]
				},
				"insertReplaceSupport": true,
				"resolveSupport": {
					"properties": [
						"additionalTextEdits",
						"command",
						"detail",
						"documentation"
					]
				},
				"insertTextModeSupport": {
					"valueSet": [
						1,
						2
					]
				},
				"labelDetailsSupport": true
			},
			"insertTextMode": 2,
			"contextSupport": true,
			"completionList": {
				"itemDefaults": [
					"commitCharacters",
					"editRange",
					"insertTextMode",
					"insertTextFormat",
					"data"
				]
			}
		},
		"hover": {
			"dynamicRegistration": true,
			"contentFormat": [
				"markdown"
			]
		},
		"signatureHelp": {
			"dynamicRegistration": true,
			"signatureInformation": {
				"documentationFormat": [
					"markdown",
					"plaintext"
				],
				"parameterInformation": {
					"labelOffsetSupport": true
				},
				"activeParameterSupport": true
			}
		},
		"definition": {
			"dynamicRegistration": true,
			"linkSupport": true
		},
		"documentSymbol": {
			"dynamicRegistration": true,
			"hierarchicalDocumentSymbolSupport": true
		},
		"codeAction": {
			"dynamicRegistration": true,
			"codeActionLiteralSupport": {
				"codeActionKind": {
					"valueSet": [
						"refactor",
						"quickfix",
						"source"
					]
				}
			},
			"dataSupport": true,
			"resolveSupport": {
				"properties": [
					"kind",
					"diagnostics",
					"isPreferred",
					"disabled",
					"edit",
					"command"
				]
			}
		},
		"codeLens": {
			"dynamicRegistration": true
		},
		"colorProvider": {
			"dynamicRegistration": true
		},
		"formatting": {
			"dynamicRegistration": true
		},
		"rangeFormatting": {
			"dynamicRegistration": true
		},
		"onTypeFormatting": {
			"dynamicRegistration": true
		},
		"rename": {
			"dynamicRegistration": true,
			"prepareSupport": true,
			"prepareSupportDefaultBehavior": 1
		},
		"foldingRange": {
			"dynamicRegistration": true,
			"foldingRangeKind": {
				"valueSet": [
					"comment",
					"region",
					"imports"
				]
			},
			"foldingRange": {
				"collapsedText": true
			}
		},
		"publishDiagnostics": {
			"relatedInformation": true,
			"tagSupport": {
				"valueSet": [
					1,
					2
				]
			},
			"codeDescriptionSupport": true,
			"dataSupport": true,
			"versionSupport": true
		},
		"semanticTokens": {
			"requests": {
				"full": {
					"delta": true
				}
			},
			"tokenTypes": [
				"namespace",
				"class",
				"enum",
				"interface",
				"struct",
				"typeParameter",
				"type",
				"parameter",
				"variable",
				"property",
				"enumMember",
				"decorator",
				"function",
				"method",
				"macro",
				"label",
				"comment",
				"string",
				"keyword",
				"number",
				"regexp",
				"operator",
				"modifier",
				"event",
				"lifetime"
			],
			"tokenModifiers": [
				"declaration",
				"definition",
				"readonly",
				"static",
				"deprecated",
				"abstract",
				"async",
				"modification",
				"documentation",
				"defaultLibrary",
				"constant"
			],
			"formats": [
				"relative"
			],
			"overlappingTokenSupport": true,
			"multilineTokenSupport": true,
			"serverCancelSupport": true,
			"augmentsSyntaxTokens": true
		},
		"inlayHint": {
			"dynamicRegistration": true,
			"resolveSupport": {
				"properties": [
					"textEdits",
					"tooltip",
					"label.tooltip",
					"label.location",
					"label.command"
				]
			}
		},
		"diagnostic": {
			"dynamicRegistration": true,
			"relatedDocumentSupport": true
		}
	},
	"window": {
		"workDoneProgress": true,
		"showMessage": {
			"messageActionItem": {
				"additionalPropertiesSupport": true
			}
		}
	},
	"general": {
		"positionEncodings": [
			"utf-16"
		]
	}
}
received options from workspace/configuration request:
js/ts: <nil>

typescript: <nil>

javascript: <nil>

editor: <nil>
handled method 'initialized' in 1.878452ms
handled method 'workspace/didChangeConfiguration' in 581ns
Processed 1 file changes in 16.401µs
handled method 'textDocument/didOpen' in 108.791986ms
handled method 'textDocument/documentHighlight' (3) in 1.491297ms
======== Cloning snapshot 1 ========
[14:54:13.268] Reason: RequestedLanguageService (pending file changes) -  Documents: [file:///home/mybearworld/Desktop/programs/e/ts.ts]
[14:54:13.268] DidChangeCustomConfigFileName
[14:54:13.268] DidRequestFile
[14:54:13.268] UpdateAutoImports
	[14:54:13.268] Building autoimport registry
		[14:54:13.269] Updated buckets and directories in 40.946µs
		[14:54:13.269] Built autoimport registry in 43.972µs
[14:54:13.269] Finished cloning snapshot 1 into snapshot 2 in 65.391µs

======== Runtime Metrics ========
/gc/cleanups/executed:cleanups = 0
/gc/cleanups/queued:cleanups = 0
/gc/cycles/automatic:gc-cycles = 4
/gc/cycles/forced:gc-cycles = 0
/gc/cycles/total:gc-cycles = 4
/gc/finalizers/executed:finalizers = 0
/gc/finalizers/queued:finalizers = 0
/gc/gogc:percent = 100
/gc/gomemlimit:bytes = 9223372036854775807
/gc/heap/allocs:bytes = 27048064
/gc/heap/allocs:objects = 46099
/gc/heap/frees:bytes = 1682360
/gc/heap/frees:objects = 6687
/gc/heap/goal:bytes = 47511802
/gc/heap/live:bytes = 23546960
/gc/heap/objects:objects = 39412
/gc/heap/tiny/allocs:objects = 1790
/gc/limiter/last-enabled:gc-cycle = 0
/gc/scan/globals:bytes = 399978
/gc/scan/heap:bytes = 17891592
/gc/scan/stack:bytes = 17904
/gc/scan/total:bytes = 18309474
/gc/stack/starting-size:bytes = 2048
/memory/classes/heap/free:bytes = 0
/memory/classes/heap/objects:bytes = 25365704
/memory/classes/heap/released:bytes = 5529600
/memory/classes/heap/stacks:bytes = 753664
/memory/classes/heap/unused:bytes = 1905464
/memory/classes/metadata/mcache/free:bytes = 11480
/memory/classes/metadata/mcache/inuse:bytes = 4592
/memory/classes/metadata/mspan/free:bytes = 9440
/memory/classes/metadata/mspan/inuse:bytes = 219040
/memory/classes/metadata/other:bytes = 3733248
/memory/classes/os-stacks:bytes = 0
/memory/classes/other:bytes = 497707
/memory/classes/profiling/buckets:bytes = 1466021
/memory/classes/total:bytes = 39495960

Updated watches in 5.17µs
handled method 'textDocument/diagnostic' (2) in 2.478852ms
======== Cloning snapshot 0 ========
[14:54:13.160] Reason: DidOpenFile - file:///home/mybearworld/Desktop/programs/e/ts.ts
[14:54:13.160] DidChangeCustomConfigFileName
[14:54:13.160] DidChangeFiles
	[14:54:13.160] Checking for changes affecting config files
		[14:54:13.160] Summarizing file changes
		[14:54:13.160] Checking if any changed files are config files
	[14:54:13.160] computeConfigFileName:: File: /home/mybearworld/Desktop/programs/e/ts.ts:: Result: 
	[14:54:13.160] Creating InferredProject: /dev/null/inferred, currentDirectory: /home/mybearworld/Desktop/programs/e
[14:54:13.160] DidRequestFile
	[14:54:13.160] CompilerHost
	[14:54:13.268] Program update for /dev/null/inferred completed in 108.232542ms
	[14:54:13.268] Completed file request for /home/mybearworld/Desktop/programs/e/ts.ts in 108.249073ms
[14:54:13.268] Removed 0 cached file(s) in 61.704µs
[14:54:13.268] UpdateAutoImports
	[14:54:13.268] Building autoimport registry
		[14:54:13.268] Added project: /dev/null/inferred
		[14:54:13.268] Added directory: /home
		[14:54:13.268] Added directory: /
		[14:54:13.268] Added directory: /home/mybearworld/Desktop/programs/e
		[14:54:13.268] Added directory: /home/mybearworld/Desktop/programs
		[14:54:13.268] Added directory: /home/mybearworld/Desktop
		[14:54:13.268] Added directory: /home/mybearworld
		[14:54:13.268] Updated buckets and directories in 91.629µs
		[14:54:13.268] Built autoimport registry in 100.676µs
[14:54:13.268] Finished cloning snapshot 0 into snapshot 1 in 108.729801ms

Project '/dev/null/inferred'
	Files (83)
-----------------------------------------------

======== Cache Statistics ========
Open file count:        1
Cached disk files:     82
Project count:          1
Config count:           0

======== Runtime Metrics ========
/gc/cleanups/executed:cleanups = 0
/gc/cleanups/queued:cleanups = 0
/gc/cycles/automatic:gc-cycles = 4
/gc/cycles/forced:gc-cycles = 0
/gc/cycles/total:gc-cycles = 4
/gc/finalizers/executed:finalizers = 0
/gc/finalizers/queued:finalizers = 0
/gc/gogc:percent = 100
/gc/gomemlimit:bytes = 9223372036854775807
/gc/heap/allocs:bytes = 27072144
/gc/heap/allocs:objects = 46523
/gc/heap/frees:bytes = 1682360
/gc/heap/frees:objects = 6687
/gc/heap/goal:bytes = 47511802
/gc/heap/live:bytes = 23546960
/gc/heap/objects:objects = 39836
/gc/heap/tiny/allocs:objects = 1854
/gc/limiter/last-enabled:gc-cycle = 0
/gc/scan/globals:bytes = 399978
/gc/scan/heap:bytes = 17929568
/gc/scan/stack:bytes = 17904
/gc/scan/total:bytes = 18347450
/gc/stack/starting-size:bytes = 2048
/memory/classes/heap/free:bytes = 0
/memory/classes/heap/objects:bytes = 25389784
/memory/classes/heap/released:bytes = 5447680
/memory/classes/heap/stacks:bytes = 753664
/memory/classes/heap/unused:bytes = 1963304
/memory/classes/metadata/mcache/free:bytes = 11480
/memory/classes/metadata/mcache/inuse:bytes = 4592
/memory/classes/metadata/mspan/free:bytes = 9440
/memory/classes/metadata/mspan/inuse:bytes = 219040
/memory/classes/metadata/other:bytes = 3746560
/memory/classes/os-stacks:bytes = 0
/memory/classes/other:bytes = 484395
/memory/classes/profiling/buckets:bytes = 1466021
/memory/classes/total:bytes = 39495960

Added new watch: program files for /dev/null/inferred watcher 4.0
	/home/mybearworld/Desktop/programs/e/**/*

Added new watch: program files for /dev/null/inferred watcher 4.1
	/home/mybearworld/.local/share/zed/extensions/work/tsgo/node_modules/@typescript/native-preview-linux-x64/lib/**/*

Added new watch: program files for /dev/null/inferred watcher 4.2
	/home/mybearworld/Desktop/**/*

3 paths ineligible for watching
Updated watches in 27.475041ms
handled method 'textDocument/codeAction' (4) in 92.852µs
handled method 'textDocument/codeLens' (5) in 51.725µs
Scheduling new diagnostics refresh...
handled method 'workspace/didChangeWatchedFiles' in 29.014µs
Processed 1 file changes in 21.57µs
======== Cloning snapshot 2 ========
[14:54:23.819] Reason: RequestedLanguageService (pending file changes) -  Documents: [file:///home/mybearworld/Desktop/programs/e/ts.ts]
[14:54:23.819] DidChangeCustomConfigFileName
[14:54:23.819] DidChangeFiles
	[14:54:23.819] Checking for changes affecting config files
		[14:54:23.819] Summarizing file changes
		[14:54:23.819] Checking if any changed files are config files
[14:54:23.819] DidRequestFile
[14:54:23.820] UpdateAutoImports
	[14:54:23.820] Building autoimport registry
		[14:54:23.820] Updated buckets and directories in 27.571µs
		[14:54:23.820] Built autoimport registry in 36.848µs
[14:54:23.820] Finished cloning snapshot 2 into snapshot 3 in 143.646µs

======== Runtime Metrics ========
/gc/cleanups/executed:cleanups = 0
/gc/cleanups/queued:cleanups = 0
/gc/cycles/automatic:gc-cycles = 5
/gc/cycles/forced:gc-cycles = 0
/gc/cycles/total:gc-cycles = 5
/gc/finalizers/executed:finalizers = 0
/gc/finalizers/queued:finalizers = 0
/gc/gogc:percent = 100
/gc/gomemlimit:bytes = 9223372036854775807
/gc/heap/allocs:bytes = 51754968
/gc/heap/allocs:objects = 189785
/gc/heap/frees:bytes = 8428672
/gc/heap/frees:objects = 26485
/gc/heap/goal:bytes = 69210242
/gc/heap/live:bytes = 34398256
/gc/heap/objects:objects = 163300
/gc/heap/tiny/allocs:objects = 128336
/gc/limiter/last-enabled:gc-cycle = 0
/gc/scan/globals:bytes = 399978
/gc/scan/heap:bytes = 33662376
/gc/scan/stack:bytes = 13752
/gc/scan/total:bytes = 34076106
/gc/stack/starting-size:bytes = 2048
/memory/classes/heap/free:bytes = 0
/memory/classes/heap/objects:bytes = 43326296
/memory/classes/heap/released:bytes = 3964928
/memory/classes/heap/stacks:bytes = 786432
/memory/classes/heap/unused:bytes = 2253992
/memory/classes/metadata/mcache/free:bytes = 11480
/memory/classes/metadata/mcache/inuse:bytes = 4592
/memory/classes/metadata/mspan/free:bytes = 160
/memory/classes/metadata/mspan/inuse:bytes = 505760
/memory/classes/metadata/other:bytes = 3813632
/memory/classes/os-stacks:bytes = 0
/memory/classes/other:bytes = 660155
/memory/classes/profiling/buckets:bytes = 1470037
/memory/classes/total:bytes = 56797464

Updated watches in 6.041µs
handled method 'textDocument/diagnostic' (6) in 886.889µs
Delaying scheduled diagnostics refresh...
handled method 'workspace/didChangeWatchedFiles' in 29.836µs
Running scheduled diagnostics refresh
Error refreshing diagnostics: failed to refresh diagnostics: request failed: [-32700]: invalid type: map, expected unit
Processed 1 file changes in 13.385µs
handled method 'textDocument/diagnostic' (7) in 150.968µs
======== Cloning snapshot 3 ========
[14:54:31.526] Reason: RequestedLanguageService (pending file changes) -  Documents: [file:///home/mybearworld/Desktop/programs/e/ts.ts]
[14:54:31.526] DidChangeCustomConfigFileName
[14:54:31.526] DidChangeFiles
	[14:54:31.526] Checking for changes affecting config files
		[14:54:31.526] Summarizing file changes
		[14:54:31.526] Checking if any changed files are config files
[14:54:31.526] DidRequestFile
[14:54:31.526] UpdateAutoImports
	[14:54:31.526] Building autoimport registry
		[14:54:31.526] Updated buckets and directories in 14.146µs
		[14:54:31.526] Built autoimport registry in 29.344µs
[14:54:31.526] Finished cloning snapshot 3 into snapshot 4 in 71.222µs

======== Runtime Metrics ========
/gc/cleanups/executed:cleanups = 0
/gc/cleanups/queued:cleanups = 0
/gc/cycles/automatic:gc-cycles = 5
/gc/cycles/forced:gc-cycles = 0
/gc/cycles/total:gc-cycles = 5
/gc/finalizers/executed:finalizers = 0
/gc/finalizers/queued:finalizers = 0
/gc/gogc:percent = 100
/gc/gomemlimit:bytes = 9223372036854775807
/gc/heap/allocs:bytes = 51760904
/gc/heap/allocs:objects = 189871
/gc/heap/frees:bytes = 8428672
/gc/heap/frees:objects = 26485
/gc/heap/goal:bytes = 69210242
/gc/heap/live:bytes = 34398256
/gc/heap/objects:objects = 163386
/gc/heap/tiny/allocs:objects = 128336
/gc/limiter/last-enabled:gc-cycle = 0
/gc/scan/globals:bytes = 399978
/gc/scan/heap:bytes = 33688000
/gc/scan/stack:bytes = 13752
/gc/scan/total:bytes = 34101730
/gc/stack/starting-size:bytes = 2048
/memory/classes/heap/free:bytes = 0
/memory/classes/heap/objects:bytes = 43332232
/memory/classes/heap/released:bytes = 3915776
/memory/classes/heap/stacks:bytes = 786432
/memory/classes/heap/unused:bytes = 2297208
/memory/classes/metadata/mcache/free:bytes = 11480
/memory/classes/metadata/mcache/inuse:bytes = 4592
/memory/classes/metadata/mspan/free:bytes = 160
/memory/classes/metadata/mspan/inuse:bytes = 505760
/memory/classes/metadata/other:bytes = 3820288
/memory/classes/os-stacks:bytes = 0
/memory/classes/other:bytes = 653499
/memory/classes/profiling/buckets:bytes = 1470037
/memory/classes/total:bytes = 56797464

Updated watches in 3.256µs
Scheduling new diagnostics refresh...
handled method 'workspace/didChangeWatchedFiles' in 23.343µs
Canceled scheduled diagnostics refresh
handled method 'textDocument/didSave' in 21.94µs
panic: lsproto.DocumentUri("overlay not found for saved file: file:///home/mybearworld/Desktop/programs/e/css2.css")

goroutine 6 [running]:
github.com/microsoft/typescript-go/internal/project.(*overlayFS).processChanges(0x5a91ef70500, {0x5a91f87e6e0, 0x2, 0x5a91ef6b658?})
	github.com/microsoft/typescript-go/internal/project/overlayfs.go:369 +0xf7b
github.com/microsoft/typescript-go/internal/project.(*Session).flushChangesLocked(0x5a91ef72dc0, {0x10df150?, 0x5a91eee2000?})
	github.com/microsoft/typescript-go/internal/project/session.go:858 +0xb9
github.com/microsoft/typescript-go/internal/project.(*Session).flushChanges(0x5a91ef72dc0, {0x10df118, 0x5a9216cfc20})
	github.com/microsoft/typescript-go/internal/project/session.go:840 +0x1e5
github.com/microsoft/typescript-go/internal/project.(*Session).getSnapshot(0x5a91ef72dc0, {0x10df118, 0x5a9216cfc20}, {{0x5a9216ccc20, 0x1, 0x1}, {0x0, 0x0, 0x0}, {0x0, ...}, ...})
	github.com/microsoft/typescript-go/internal/project/session.go:458 +0xf1
github.com/microsoft/typescript-go/internal/project.(*Session).getSnapshotAndDefaultProject(0x5a91ef72dc0, {0x10df118, 0x5a9216cfc20}, {0x5a92094e080, 0x31})
	github.com/microsoft/typescript-go/internal/project/session.go:518 +0x12a
github.com/microsoft/typescript-go/internal/project.(*Session).GetLanguageService(0x0?, {0x10df118?, 0x5a9216cfc20?}, {0x5a92094e080?, 0x0?})
	github.com/microsoft/typescript-go/internal/project/session.go:530 +0x25
github.com/microsoft/typescript-go/internal/lsp.init.func1.registerLanguageServiceDocumentRequestHandler[...].12({0x10df118, 0x5a9216cfc20}, 0x5a921a96ea0)
	github.com/microsoft/typescript-go/internal/lsp/server.go:773 +0x8a
github.com/microsoft/typescript-go/internal/lsp.(*Server).handleRequestOrNotification(0x5a91efc9508, {0x10df150?, 0x5a91ef70910?}, 0x5a921a96ea0)
	github.com/microsoft/typescript-go/internal/lsp/server.go:621 +0xec
github.com/microsoft/typescript-go/internal/lsp.(*Server).dispatchLoop(0x5a91efc9508, {0x10df150?, 0x5a91eee2000?})
	github.com/microsoft/typescript-go/internal/lsp/server.go:500 +0x41e
github.com/microsoft/typescript-go/internal/lsp.(*Server).Run.func1()
	github.com/microsoft/typescript-go/internal/lsp/server.go:363 +0x1f
golang.org/x/sync/errgroup.(*Group).Go.func1()
	golang.org/x/sync@v0.20.0/errgroup/errgroup.go:93 +0x50
created by golang.org/x/sync/errgroup.(*Group).Go in goroutine 1
	golang.org/x/sync@v0.20.0/errgroup/errgroup.go:78 +0x95

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions