textDocument/diagnostic failed
I seem to get this all the time:
last time I checked the logs I couldn't find anything around the time I checked, but this time I see this panic (and this panic is in my logs several times a day)
Is the below panic expected or the cause of the above?
Logs:
======== Cloning snapshot 339 ========
[14:56:30.043] Reason: RequestedLanguageService (project dirty) - [file:///c%3A/Projects/x/y/z]
[14:56:30.043] DidRequestFile
[14:56:30.043] Acquiring config for project
[14:56:30.043] CompilerHost
panic: parse cache entry not found [recovered, repanicked]
goroutine 4680420 [running]:
github.com/microsoft/typescript-go/internal/project.(*Snapshot).Clone.func1()
github.com/microsoft/typescript-go/internal/project/snapshot.go:174 +0x7d
panic({0x7ff6411298a0?, 0x7ff6414bd560?})
runtime/panic.go:783 +0x132
github.com/microsoft/typescript-go/internal/project.(*ParseCache).Ref(0xc0daf614a0?, 0xc0132fd310?)
github.com/microsoft/typescript-go/internal/project/parsecache.go:69 +0x194
github.com/microsoft/typescript-go/internal/project.(*Project).CreateProgram(0xc125859c00)
github.com/microsoft/typescript-go/internal/project/project.go:293 +0x30e
github.com/microsoft/typescript-go/internal/project.(*projectCollectionBuilder).updateProgram.func1.2(0xc125859c00)
github.com/microsoft/typescript-go/internal/project/projectcollectionbuilder.go:797 +0x1fd
github.com/microsoft/typescript-go/internal/project/dirty.(*SyncMapEntry[...]).changeLocked(0x7ff6414db520, 0xc11107ef40)
github.com/microsoft/typescript-go/internal/project/dirty/syncmap.go:124 +0x18b
github.com/microsoft/typescript-go/internal/project/dirty.(*lockedEntry[...]).Change(...)
github.com/microsoft/typescript-go/internal/project/dirty/syncmap.go:27
github.com/microsoft/typescript-go/internal/project.(*projectCollectionBuilder).updateProgram.func1({0x7ff6414c7f00, 0xc10ed3b5f0})
github.com/microsoft/typescript-go/internal/project/projectcollectionbuilder.go:794 +0x264
github.com/microsoft/typescript-go/internal/project/dirty.(*SyncMapEntry[...]).Locked(0x7ff6414db520, 0xc088689080)
github.com/microsoft/typescript-go/internal/project/dirty/syncmap.go:90 +0xd5
github.com/microsoft/typescript-go/internal/project.(*projectCollectionBuilder).updateProgram(0xc11594f280, {0x7ff6414c88e0, 0xc11ab69d40}, 0xc107d20eb0)
github.com/microsoft/typescript-go/internal/project/projectcollectionbuilder.go:769 +0x13c
github.com/microsoft/typescript-go/internal/project.(*projectCollectionBuilder).DidRequestFile(0xc11594f280, {0xc0f4c2b2d0, 0x6e}, 0xc107d20eb0)
github.com/microsoft/typescript-go/internal/project/projectcollectionbuilder.go:298 +0xf2
github.com/microsoft/typescript-go/internal/project.(*Snapshot).Clone(0xc111406200, {0x7ff6414c4da0, 0xc107d20d70}, {0x5, {{0x0, 0x0}, 0x0, {0x0}, {0x0}, {0x0}, ...}, ...}, ...)
github.com/microsoft/typescript-go/internal/project/snapshot.go:247 +0xa8c
github.com/microsoft/typescript-go/internal/project.(*Session).UpdateSnapshot(0xc0000c4a20, {0x7ff6414c4da0, 0xc107d20d70}, 0xc085008cc0, {0x5, {{0x0, 0x0}, 0x0, {0x0}, {0x0}, ...}, ...})
github.com/microsoft/typescript-go/internal/project/session.go:414 +0xb3
github.com/microsoft/typescript-go/internal/project.(*Session).GetLanguageService(0xc0000c4a20, {0x7ff6414c4da0, 0xc107d20d70}, {0xc0f4c2b2d0, 0x6e})
github.com/microsoft/typescript-go/internal/project/session.go:399 +0x4f8
github.com/microsoft/typescript-go/internal/lsp.init.func1.registerLanguageServiceDocumentRequestHandler[...].12({0x7ff6414c4da0, 0xc107d20d70}, 0xc1105f58f0)
github.com/microsoft/typescript-go/internal/lsp/server.go:549 +0xbc
github.com/microsoft/typescript-go/internal/lsp.(*Server).handleRequestOrNotification(0xc000166dc0, {0x7ff6414c4da0, 0xc107d20d70}, 0xc1105f58f0)
github.com/microsoft/typescript-go/internal/lsp/server.go:449 +0x10d
github.com/microsoft/typescript-go/internal/lsp.(*Server).dispatchLoop.func1()
github.com/microsoft/typescript-go/internal/lsp/server.go:354 +0x3a
created by github.com/microsoft/typescript-go/internal/lsp.(*Server).dispatchLoop in goroutine 23
github.com/microsoft/typescript-go/internal/lsp/server.go:374 +0x9ad
[Info - 2:56:30 PM] Connection to server got closed. Server will restart.
true
configuration: [map[autoClosingTags:true check:map[npmIsInstalled:true] disableAutomaticTypeAcquisition:false enablePromptUseWorkspaceTsdk:false experimental:map[useTsgo:true] format:map[enable:true indentSwitchCase:true insertSpaceAfterCommaDelimiter:true insertSpaceAfterConstructor:false insertSpaceAfterFunctionKeywordForAnonymousFunctions:true insertSpaceAfterKeywordsInControlFlowStatements:true insertSpaceAfterOpeningAndBeforeClosingEmptyBraces:true insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces:false insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces:true insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets:false insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis:false insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces:false insertSpaceAfterSemicolonInForStatements:true insertSpaceAfterTypeAssertion:false insertSpaceBeforeAndAfterBinaryOperators:true insertSpaceBeforeFunctionParenthesis:false placeOpenBraceOnNewLineForControlBlocks:false placeOpenBraceOnNewLineForFunctions:false semicolons:ignore] implementationsCodeLens:map[enabled:false showOnInterfaceMethods:false] inlayHints:map[enumMemberValues:map[enabled:false] functionLikeReturnTypes:map[enabled:false] parameterNames:map[enabled:all suppressWhenArgumentMatchesName:true] parameterTypes:map[enabled:true] propertyDeclarationTypes:map[enabled:true] variableTypes:map[enabled:true suppressWhenTypeMatchesName:true]] locale:auto native-preview:map[pprofDir: trace:map[server:verbose] tsdk:] npm: preferGoToSourceDefinition:false preferences:map[autoImportFileExcludePatterns:[] autoImportSpecifierExcludeRegexes:[] importModuleSpecifier:shortest importModuleSpecifierEnding:auto includePackageJsonAutoImports:auto jsxAttributeCompletionStyle:auto organizeImports:map[] preferTypeOnlyAutoImports:false quoteStyle:auto renameMatchingJsxTags:true useAliasesForRenames:true] referencesCodeLens:map[enabled:false showOnAllFunctions:false] reportStyleChecksAsWarnings:true suggest:map[autoImports:true classMemberSnippets:map[enabled:true] completeFunctionCalls:false completeJSDocs:true enabled:true includeAutomaticOptionalChainCompletions:true includeCompletionsForImportStatements:true jsdoc:map[generateReturns:true] objectLiteralMethodSnippets:map[enabled:true] paths:true] suggestionActions:map[enabled:true] tsc:map[autoDetect:on] tsdk: tsserver:map[enableRegionDiagnostics:true enableTracing:false experimental:map[enableProjectDiagnostics:false] log:off maxTsServerMemory:12072 nodePath: pluginPaths:[] useSyntaxServer:auto watchOptions:vscode web:map[projectWideIntellisense:map[enabled:true suppressSemanticErrors:false] typeAcquisition:map[enabled:true]]] updateImportsOnFileMove:map[enabled:prompt] updateImportsOnPaste:map[enabled:false] validate:map[enable:true] workspaceSymbols:map[excludeLibrarySymbols:true scope:allOpenProjects]]], []interface {}
[14:56:30.148] Processed 1 file changes in 0s
[Error - 2:56:30 PM] Server process exited with code 2.
[14:56:32.003] Processed 1 file changes in 0s
LSP logs show a lot of:
[Trace - 2:56:30 PM] Received response 'textDocument/diagnostic - (1388)' in 13818ms. Request failed: RequestCancelled (-32800).
[Trace - 2:56:30 PM] Sending request 'textDocument/diagnostic - (1390)'.
I think it tends to happen when I do a big operation e.g. like a replaceAll across files.
Not related to the crash, but I would love to see the cache stats printed with "typescript.native-preview.trace.server": "verbose"
@andrewbranch I haven't reproduced again with stats but this is what it looks like for the project getting this:
======== Cache Statistics ========
[09:36:54.252] Open file count: 560
[09:36:54.252] Cached disk files: 25294
[09:36:54.252] Project count: 12
[09:36:54.252] Config count: 14
[09:36:54.252] Parse cache size: 26665
[09:36:54.252] Program count: 12
[09:36:54.252] Extended config cache size: 1
I'll lookout for the crash and update if the cache statistics are different when it errors.
560 open files?? 😅
@andrewbranch I did a search and replace in files and that seems to bump up open files even though they were never all open in my editor...
Can you re-open? it just happened on the latest vscode.
I'm not sure if it causes a popup though - I get errors all the time and quite often I can't find a panic and this panic happened earlier than when the popup appeared.
======== Cache Statistics ========
[11:17:11.227] Open file count: 21
[11:17:11.227] Cached disk files: 19397
[11:17:11.227] Project count: 4
[11:17:11.227] Config count: 5
[11:17:11.227] Parse cache size: 20687
[11:17:11.227] Program count: 4
[11:17:11.227] Extended config cache size: 1
[11:17:11.227] Updated watches in 0s
======== Cloning snapshot 749 ========
[11:17:13.649] Reason: RequestedLanguageService (project dirty) - [file:///c%3A/Projects/x/y/z/a/b.ts]
[11:17:13.649] DidRequestFile
[11:17:13.649] Acquiring config for project
[11:17:13.649] CompilerHost
panic: parse cache entry not found [recovered, repanicked]
goroutine 6661175 [running]:
github.com/microsoft/typescript-go/internal/project.(*Snapshot).Clone.func1()
github.com/microsoft/typescript-go/internal/project/snapshot.go:175 +0x7d
panic({0x7ff658b6dae0?, 0x7ff658f05e40?})
runtime/panic.go:783 +0x132
github.com/microsoft/typescript-go/internal/project.(*ParseCache).Ref(0xc000315800, 0xc1568083c0?)
github.com/microsoft/typescript-go/internal/project/parsecache.go:80 +0x248
github.com/microsoft/typescript-go/internal/project.(*Project).CreateProgram(0xc0ae631260)
github.com/microsoft/typescript-go/internal/project/project.go:293 +0x30e
github.com/microsoft/typescript-go/internal/project.(*ProjectCollectionBuilder).updateProgram.func1.2(0xc0ae631260)
github.com/microsoft/typescript-go/internal/project/projectcollectionbuilder.go:797 +0x1fd
github.com/microsoft/typescript-go/internal/project/dirty.(*SyncMapEntry[...]).changeLocked(0x7ff658f240e0, 0xc13874ad00)
github.com/microsoft/typescript-go/internal/project/dirty/syncmap.go:124 +0x18b
github.com/microsoft/typescript-go/internal/project/dirty.(*lockedEntry[...]).Change(...)
github.com/microsoft/typescript-go/internal/project/dirty/syncmap.go:27
github.com/microsoft/typescript-go/internal/project.(*ProjectCollectionBuilder).updateProgram.func1({0x7ff658f109c0, 0xc0d22f7f08})
github.com/microsoft/typescript-go/internal/project/projectcollectionbuilder.go:794 +0x264
github.com/microsoft/typescript-go/internal/project/dirty.(*SyncMapEntry[...]).Locked(0x7ff658f240e0, 0xc0b92f8660)
github.com/microsoft/typescript-go/internal/project/dirty/syncmap.go:90 +0xd5
github.com/microsoft/typescript-go/internal/project.(*ProjectCollectionBuilder).updateProgram(0xc0359cc000, {0x7ff658f113a0, 0xc105b38540}, 0xc168ae3450)
github.com/microsoft/typescript-go/internal/project/projectcollectionbuilder.go:769 +0x13c
github.com/microsoft/typescript-go/internal/project.(*ProjectCollectionBuilder).DidRequestFile(0xc0359cc000, {0xc1135d6000, 0x4c}, 0xc168ae3450)
github.com/microsoft/typescript-go/internal/project/projectcollectionbuilder.go:298 +0xf2
github.com/microsoft/typescript-go/internal/project.(*Snapshot).Clone(0xc14e90ff00, {0x7ff658f0d860, 0xc168ae2e60}, {0x5, {{0x0, 0x0}, 0x0, {0x0}, {0x0}, {0x0}, ...}, ...}, ...)
github.com/microsoft/typescript-go/internal/project/snapshot.go:248 +0xa8c
github.com/microsoft/typescript-go/internal/project.(*Session).UpdateSnapshot(0xc000322b40, {0x7ff658f0d860, 0xc168ae2e60}, 0xc019308720, {0x5, {{0x0, 0x0}, 0x0, {0x0}, {0x0}, ...}, ...})
github.com/microsoft/typescript-go/internal/project/session.go:415 +0xb3
github.com/microsoft/typescript-go/internal/project.(*Session).GetLanguageService(0xc000322b40, {0x7ff658f0d860, 0xc168ae2e60}, {0xc1135d6000, 0x4c})
github.com/microsoft/typescript-go/internal/project/session.go:400 +0x4f8
github.com/microsoft/typescript-go/internal/lsp.init.func1.registerLanguageServiceDocumentRequestHandler[...].12({0x7ff658f0d860, 0xc168ae2e60}, 0xc0b77f2630)
github.com/microsoft/typescript-go/internal/lsp/server.go:553 +0xbc
github.com/microsoft/typescript-go/internal/lsp.(*Server).handleRequestOrNotification(0xc0000ecdc0, {0x7ff658f0d860, 0xc168ae2e60}, 0xc0b77f2630)
github.com/microsoft/typescript-go/internal/lsp/server.go:451 +0x10d
github.com/microsoft/typescript-go/internal/lsp.(*Server).dispatchLoop.func1()
github.com/microsoft/typescript-go/internal/lsp/server.go:356 +0x3a
created by github.com/microsoft/typescript-go/internal/lsp.(*Server).dispatchLoop in goroutine 10
github.com/microsoft/typescript-go/internal/lsp/server.go:376 +0x9ad
[Info - 11:17:13 AM] Connection to server got closed. Server will restart.
true
configuration: [map[autoClosingTags:true check:map[npmIsInstalled:true] disableAutomaticTypeAcquisition:false enablePromptUseWorkspaceTsdk:false experimental:map[useTsgo:true] format:map[enable:true indentSwitchCase:true insertSpaceAfterCommaDelimiter:true insertSpaceAfterConstructor:false insertSpaceAfterFunctionKeywordForAnonymousFunctions:true insertSpaceAfterKeywordsInControlFlowStatements:true insertSpaceAfterOpeningAndBeforeClosingEmptyBraces:true insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces:false insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces:true insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets:false insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis:false insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces:false insertSpaceAfterSemicolonInForStatements:true insertSpaceAfterTypeAssertion:false insertSpaceBeforeAndAfterBinaryOperators:true insertSpaceBeforeFunctionParenthesis:false placeOpenBraceOnNewLineForControlBlocks:false placeOpenBraceOnNewLineForFunctions:false semicolons:ignore] implementationsCodeLens:map[enabled:false showOnInterfaceMethods:false] inlayHints:map[enumMemberValues:map[enabled:false] functionLikeReturnTypes:map[enabled:false] parameterNames:map[enabled:all suppressWhenArgumentMatchesName:true] parameterTypes:map[enabled:true] propertyDeclarationTypes:map[enabled:true] variableTypes:map[enabled:true suppressWhenTypeMatchesName:true]] locale:auto native-preview:map[pprofDir: trace:map[server:verbose] tsdk:] npm: preferGoToSourceDefinition:false preferences:map[autoImportFileExcludePatterns:[] autoImportSpecifierExcludeRegexes:[] importModuleSpecifier:shortest importModuleSpecifierEnding:auto includePackageJsonAutoImports:auto jsxAttributeCompletionStyle:auto organizeImports:map[] preferTypeOnlyAutoImports:false quoteStyle:auto renameMatchingJsxTags:true useAliasesForRenames:true] referencesCodeLens:map[enabled:false showOnAllFunctions:false] reportStyleChecksAsWarnings:true suggest:map[autoImports:true classMemberSnippets:map[enabled:true] completeFunctionCalls:false completeJSDocs:true enabled:true includeAutomaticOptionalChainCompletions:true includeCompletionsForImportStatements:true jsdoc:map[generateReturns:true] objectLiteralMethodSnippets:map[enabled:true] paths:true] suggestionActions:map[enabled:true] tsc:map[autoDetect:on] tsdk: tsserver:map[enableRegionDiagnostics:true enableTracing:false experimental:map[enableProjectDiagnostics:false] log:off maxTsServerMemory:12072 nodePath: pluginPaths:[] useSyntaxServer:auto watchOptions:vscode web:map[projectWideIntellisense:map[enabled:true suppressSemanticErrors:false] typeAcquisition:map[enabled:true]]] updateImportsOnFileMove:map[enabled:prompt] updateImportsOnPaste:map[enabled:false] validate:map[enable:true] workspaceSymbols:map[excludeLibrarySymbols:true scope:allOpenProjects]]], []interface {}
[11:17:13.757] Processed 1 file changes in 0s
[Error - 11:17:14 AM] Server process exited with code 2.
[11:17:31.301] Processed 1 file changes in 0s
I can repro a failure to find a project for a file by
- Importing a file from node_modules that isn't in the program otherwise (I tried
import { findFirstMin } from '@xterm/xterm/src/vs/base/common/arraysFind.js'in VS Code) - Opening that file
- Deleting the import, thereby removing the file from the project
- Interacting with the file from node_modules
This is not related to the panic stack trace, though.