typescript-go icon indicating copy to clipboard operation
typescript-go copied to clipboard

Request textDocument/foldingRange failed.

Open eamodio opened this issue 3 weeks ago • 1 comments

Extension Version

0.20251204.1

VS Code Version

1.107.0-insider

Operating system Version

Windows_NT x64 10.0.26220

Steps to reproduce

  1. Opened a built JS file

Issue

[13:28:45.909] Open file count:        4
[13:28:45.909] Cached disk files:   3106
[13:28:45.909] Project count:          7
[13:28:45.909] Config count:           8
[13:28:45.909] Parse cache size:             2609
[13:28:45.909] Program count:                   7
[13:28:45.909] Extended config cache size:      1

panic handling request textDocument/foldingRange Token cache mismatch: parent. Expected parent of kind KindArrayLiteralExpression, got KindArrayLiteralExpression goroutine 185650 [running]:
runtime/debug.Stack()
	runtime/debug/stack.go:26 +0x5e
github.com/microsoft/typescript-go/internal/lsp.(*Server).recover(0xc0001d0008, 0xc038f8bb30)
	github.com/microsoft/typescript-go/internal/lsp/server.go:880 +0x58
panic({0x7ff67b8836c0?, 0xc02125cd40?})
	runtime/panic.go:783 +0x132
github.com/microsoft/typescript-go/internal/ast.(*SourceFile).GetOrCreateToken(0xc00374cf08, 0x16, 0x58, 0x5a, 0xc030f92050)
	github.com/microsoft/typescript-go/internal/ast/ast.go:10957 +0x305
github.com/microsoft/typescript-go/internal/astnav.FindChildOfKind.func1(0xc012a38dc8)
	github.com/microsoft/typescript-go/internal/astnav/tokens.go:693 +0xce
github.com/microsoft/typescript-go/internal/ast.visitNodes(...)
	github.com/microsoft/typescript-go/internal/ast/ast.go:28
github.com/microsoft/typescript-go/internal/ast.visitNodeList(...)
	github.com/microsoft/typescript-go/internal/ast/ast.go:37
github.com/microsoft/typescript-go/internal/ast.(*ArrayLiteralExpression).ForEachChild(0x7ff67b760901?, 0xc010eb8c40)
	github.com/microsoft/typescript-go/internal/ast/ast.go:7260 +0x67
github.com/microsoft/typescript-go/internal/ast.(*Node).ForEachChild(...)
	github.com/microsoft/typescript-go/internal/ast/ast.go:242
github.com/microsoft/typescript-go/internal/ast.ForEachChildAndJSDoc(0xc00374cf08?, 0x58?, 0xc00b377890?)
	github.com/microsoft/typescript-go/internal/ast/utilities.go:2871 +0x43
github.com/microsoft/typescript-go/internal/astnav.FindChildOfKind(0xc030f92050, 0x16, 0xc00374cf08)
	github.com/microsoft/typescript-go/internal/astnav/tokens.go:711 +0xf9
github.com/microsoft/typescript-go/internal/ls.spanForNode(0xc030f92050, 0x16, 0x1, 0xc00374cf08, 0xc0267c9d70)
	github.com/microsoft/typescript-go/internal/ls/folding.go:468 +0x32
github.com/microsoft/typescript-go/internal/ls.getOutliningSpanForNode(0xc030b015a8?, 0xc010eb8b40?, 0x2643e5925c8?)
	github.com/microsoft/typescript-go/internal/ls/folding.go:349 +0xe5
github.com/microsoft/typescript-go/internal/ls.visitNode({0x7ff67bd63b08, 0xc034e53920}, 0xc030f92050, 0x26, 0xc00374cf08, 0xc0267c9d70)
	github.com/microsoft/typescript-go/internal/ls/folding.go:151 +0x8d8
github.com/microsoft/typescript-go/internal/ls.visitNode.func1(0x7ff67b0e71a5?)
	github.com/microsoft/typescript-go/internal/ls/folding.go:194 +0x3d
github.com/microsoft/typescript-go/internal/ast.visit(...)
	github.com/microsoft/typescript-go/internal/ast/ast.go:21
github.com/microsoft/typescript-go/internal/ast.(*BinaryExpression).ForEachChild(0xc030b6b7f8, 0xc010eb8b00)
	github.com/microsoft/typescript-go/internal/ast/ast.go:6280 +0xf1
github.com/microsoft/typescript-go/internal/ast.(*Node).ForEachChild(...)
	github.com/microsoft/typescript-go/internal/ast/ast.go:242
github.com/microsoft/typescript-go/internal/ls.visitNode({0x7ff67bd63b08, 0xc034e53920}, 0xc030b6b7f8, 0x27, 0xc00374cf08, 0xc0267c9d70)
	github.com/microsoft/typescript-go/internal/ls/folding.go:200 +0xff7
github.com/microsoft/typescript-go/internal/ls.visitNode.func1(0xc0267c9d01?)
	github.com/microsoft/typescript-go/internal/ls/folding.go:194 +0x3d
github.com/microsoft/typescript-go/internal/ast.visit(...)
	github.com/microsoft/typescript-go/internal/ast/ast.go:21
github.com/microsoft/typescript-go/internal/ast.(*ExpressionStatement).ForEachChild(0xc030a4ebd0?, 0xc010eb8940?)
	github.com/microsoft/typescript-go/internal/ast/ast.go:3635 +0x23
github.com/microsoft/typescript-go/internal/ast.(*Node).ForEachChild(...)
	github.com/microsoft/typescript-go/internal/ast/ast.go:242
github.com/microsoft/typescript-go/internal/ls.visitNode({0x7ff67bd63b08, 0xc034e53920}, 0xc030f7b300, 0x28, 0xc00374cf08, 0xc0267c9d70)
	github.com/microsoft/typescript-go/internal/ls/folding.go:200 +0xff7
github.com/microsoft/typescript-go/internal/ls.(*LanguageService).addNodeOutliningSpans(0xc0267c9d70, {0x7ff67bd63b08, 0xc034e53920}, 0xc00374cf08)
	github.com/microsoft/typescript-go/internal/ls/folding.go:40 +0x41b
github.com/microsoft/typescript-go/internal/ls.(*LanguageService).ProvideFoldingRange(0xc0267c9d70, {0x7ff67bd63b08, 0xc034e53920}, {0xc039b80d00?, 0x79?})
	github.com/microsoft/typescript-go/internal/ls/folding.go:20 +0x6f
github.com/microsoft/typescript-go/internal/lsp.(*Server).handleFoldingRange(0x7ff67b145c85?, {0x7ff67bd63b08?, 0xc034e53920?}, 0xc039b80d00?, 0xc02bbe6708?)
	github.com/microsoft/typescript-go/internal/lsp/server.go:1177 +0x2b
github.com/microsoft/typescript-go/internal/lsp.init.func1.registerLanguageServiceDocumentRequestHandler[...].29({0x7ff67bd63b08, 0xc034e53920}, 0xc038f8bb30)
	github.com/microsoft/typescript-go/internal/lsp/server.go:629 +0x11a
github.com/microsoft/typescript-go/internal/lsp.(*Server).handleRequestOrNotification(0xc0001d0008, {0x7ff67bd63b40?, 0xc033d825a0?}, 0xc038f8bb30)
	github.com/microsoft/typescript-go/internal/lsp/server.go:510 +0x153
github.com/microsoft/typescript-go/internal/lsp.(*Server).dispatchLoop.func1()
	github.com/microsoft/typescript-go/internal/lsp/server.go:413 +0x3a
created by github.com/microsoft/typescript-go/internal/lsp.(*Server).dispatchLoop in goroutine 10
	github.com/microsoft/typescript-go/internal/lsp/server.go:433 +0x9ad

[Error - 1:28:45 PM] Request textDocument/foldingRange failed.
  Message: InternalError: panic handling request textDocument/foldingRange: Token cache mismatch: parent. Expected parent of kind KindArrayLiteralExpression, got KindArrayLiteralExpression
  Code: -32603 
[13:28:45.918] Updated watch: non-root program files for /dev/null/inferred watcher 373.2
[13:28:45.918] 	C:/Users/eric/AppData/Local/Microsoft/TypeScript/7.0/node_modules/**/*.{js,jsx,mjs,cjs,ts,tsx,mts,cts,json}
[13:28:45.918] 
[13:28:45.935] Updated watch: failed lookups for /dev/null/inferred watcher 375.1
[13:28:45.935] 	C:/Users/eric/AppData/Local/node_modules/**/*.{js,jsx,mjs,cjs,ts,tsx,mts,cts,json}
[13:28:45.937] 
[13:28:45.937] Updated watch: failed lookups for /dev/null/inferred watcher 375.2
[13:28:45.937] 	C:/Users/eric/node_modules/**/*.{js,jsx,mjs,cjs,ts,tsx,mts,cts,json}
[13:28:45.937] 
[13:28:45.937] Updated watch: failed lookups for /dev/null/inferred watcher 375.4
[13:28:45.937] 	d:/code/gitkraken/vscode-gitlens.worktrees/node_modules/**/*.{js,jsx,mjs,cjs,ts,tsx,mts,cts,json}
[13:28:45.937] 
[13:28:45.938] Updated watch: failed lookups for /dev/null/inferred watcher 375.5
[13:28:45.938] 	C:/Users/eric/AppData/Local/Microsoft/node_modules/**/*.{js,jsx,mjs,cjs,ts,tsx,mts,cts,json}
[13:28:45.938] 
[13:28:45.938] Updated watch: failed lookups for /dev/null/inferred watcher 375.6
[13:28:45.938] 	C:/Users/node_modules/**/*.{js,jsx,mjs,cjs,ts,tsx,mts,cts,json}
[13:28:45.938] 
[13:28:45.938] Updated watch: failed lookups for /dev/null/inferred watcher 375.7
[13:28:45.938] 	C:/Users/eric/AppData/node_modules/**/*.{js,jsx,mjs,cjs,ts,tsx,mts,cts,json}
[13:28:45.938] 
[13:28:45.939] Updated watch: failed lookups for /dev/null/inferred watcher 375.8
[13:28:45.939] 	d:/code/gitkraken/vscode-gitlens.worktrees/debt/node_modules/**/*.{js,jsx,mjs,cjs,ts,tsx,mts,cts,json}
[13:28:45.939] 
[13:28:45.939] Updated watch: failed lookups for /dev/null/inferred watcher 375.9
[13:28:45.939] 	C:/Users/eric/AppData/Local/Microsoft/TypeScript/7.0/node_modules/**/*.{js,jsx,mjs,cjs,ts,tsx,mts,cts,json}
[13:28:45.939] 
[13:28:45.939] Updated watch: failed lookups for /dev/null/inferred watcher 375.10
[13:28:45.939] 	d:/code/gitkraken/node_modules/**/*.{js,jsx,mjs,cjs,ts,tsx,mts,cts,json}
[13:28:45.939] 
[13:28:45.940] Updated watch: failed lookups for /dev/null/inferred watcher 375.11
[13:28:45.940] 	C:/Users/eric/AppData/Local/Microsoft/TypeScript/node_modules/**/*.{js,jsx,mjs,cjs,ts,tsx,mts,cts,json}
[13:28:45.940] 
[13:28:45.941] Updated watch: failed lookups for /dev/null/inferred watcher 375.12
[13:28:45.941] 	d:/node_modules/**/*.{js,jsx,mjs,cjs,ts,tsx,mts,cts,json}
[13:28:45.941] 
[13:28:45.941] Updated watch: failed lookups for /dev/null/inferred watcher 375.13
[13:28:45.941] 	C:/node_modules/**/*.{js,jsx,mjs,cjs,ts,tsx,mts,cts,json}
[13:28:45.941] 
[13:28:45.941] Updated watches in 31.934ms
[13:28:46.014] Running scheduled diagnostics refresh
panic handling request textDocument/foldingRange Token cache mismatch: parent. Expected parent of kind KindArrayLiteralExpression, got KindArrayLiteralExpression goroutine 189778 [running]:
runtime/debug.Stack()
	runtime/debug/stack.go:26 +0x5e
github.com/microsoft/typescript-go/internal/lsp.(*Server).recover(0xc0001d0008, 0xc027b036e0)
	github.com/microsoft/typescript-go/internal/lsp/server.go:880 +0x58
panic({0x7ff67b8836c0?, 0xc03170efb0?})
	runtime/panic.go:783 +0x132
github.com/microsoft/typescript-go/internal/ast.(*SourceFile).GetOrCreateToken(0xc00374cf08, 0x16, 0x58, 0x5a, 0xc030f92050)
	github.com/microsoft/typescript-go/internal/ast/ast.go:10957 +0x305
github.com/microsoft/typescript-go/internal/astnav.FindChildOfKind.func1(0xc012a38dc8)
	github.com/microsoft/typescript-go/internal/astnav/tokens.go:693 +0xce
github.com/microsoft/typescript-go/internal/ast.visitNodes(...)
	github.com/microsoft/typescript-go/internal/ast/ast.go:28
github.com/microsoft/typescript-go/internal/ast.visitNodeList(...)
	github.com/microsoft/typescript-go/internal/ast/ast.go:37
github.com/microsoft/typescript-go/internal/ast.(*ArrayLiteralExpression).ForEachChild(0x7ff67b760901?, 0xc00d5a3080)
	github.com/microsoft/typescript-go/internal/ast/ast.go:7260 +0x67
github.com/microsoft/typescript-go/internal/ast.(*Node).ForEachChild(...)
	github.com/microsoft/typescript-go/internal/ast/ast.go:242
github.com/microsoft/typescript-go/internal/ast.ForEachChildAndJSDoc(0xc00374cf08?, 0x58?, 0xc03ace7890?)
	github.com/microsoft/typescript-go/internal/ast/utilities.go:2871 +0x43
github.com/microsoft/typescript-go/internal/astnav.FindChildOfKind(0xc030f92050, 0x16, 0xc00374cf08)
	github.com/microsoft/typescript-go/internal/astnav/tokens.go:711 +0xf9
github.com/microsoft/typescript-go/internal/ls.spanForNode(0xc030f92050, 0x16, 0x1, 0xc00374cf08, 0xc027b86570)
	github.com/microsoft/typescript-go/internal/ls/folding.go:468 +0x32
github.com/microsoft/typescript-go/internal/ls.getOutliningSpanForNode(0xc030b015a8?, 0xc00d5a2f80?, 0x2643e5925c8?)
	github.com/microsoft/typescript-go/internal/ls/folding.go:349 +0xe5
github.com/microsoft/typescript-go/internal/ls.visitNode({0x7ff67bd63b08, 0xc027b86510}, 0xc030f92050, 0x26, 0xc00374cf08, 0xc027b86570)
	github.com/microsoft/typescript-go/internal/ls/folding.go:151 +0x8d8
github.com/microsoft/typescript-go/internal/ls.visitNode.func1(0x7ff67b0e71a5?)
	github.com/microsoft/typescript-go/internal/ls/folding.go:194 +0x3d
github.com/microsoft/typescript-go/internal/ast.visit(...)
	github.com/microsoft/typescript-go/internal/ast/ast.go:21
github.com/microsoft/typescript-go/internal/ast.(*BinaryExpression).ForEachChild(0xc030b6b7f8, 0xc00d5a2f40)
	github.com/microsoft/typescript-go/internal/ast/ast.go:6280 +0xf1
github.com/microsoft/typescript-go/internal/ast.(*Node).ForEachChild(...)
	github.com/microsoft/typescript-go/internal/ast/ast.go:242
github.com/microsoft/typescript-go/internal/ls.visitNode({0x7ff67bd63b08, 0xc027b86510}, 0xc030b6b7f8, 0x27, 0xc00374cf08, 0xc027b86570)
	github.com/microsoft/typescript-go/internal/ls/folding.go:200 +0xff7
github.com/microsoft/typescript-go/internal/ls.visitNode.func1(0xc027b86501?)
	github.com/microsoft/typescript-go/internal/ls/folding.go:194 +0x3d
github.com/microsoft/typescript-go/internal/ast.visit(...)
	github.com/microsoft/typescript-go/internal/ast/ast.go:21
github.com/microsoft/typescript-go/internal/ast.(*ExpressionStatement).ForEachChild(0xc030a4ebd0?, 0xc00d5a2d80?)
	github.com/microsoft/typescript-go/internal/ast/ast.go:3635 +0x23
github.com/microsoft/typescript-go/internal/ast.(*Node).ForEachChild(...)
	github.com/microsoft/typescript-go/internal/ast/ast.go:242
github.com/microsoft/typescript-go/internal/ls.visitNode({0x7ff67bd63b08, 0xc027b86510}, 0xc030f7b300, 0x28, 0xc00374cf08, 0xc027b86570)
	github.com/microsoft/typescript-go/internal/ls/folding.go:200 +0xff7
github.com/microsoft/typescript-go/internal/ls.(*LanguageService).addNodeOutliningSpans(0xc027b86570, {0x7ff67bd63b08, 0xc027b86510}, 0xc00374cf08)
	github.com/microsoft/typescript-go/internal/ls/folding.go:40 +0x41b
github.com/microsoft/typescript-go/internal/ls.(*LanguageService).ProvideFoldingRange(0xc027b86570, {0x7ff67bd63b08, 0xc027b86510}, {0xc033f77400?, 0x79?})
	github.com/microsoft/typescript-go/internal/ls/folding.go:20 +0x6f
github.com/microsoft/typescript-go/internal/lsp.(*Server).handleFoldingRange(0x7ff67b145c85?, {0x7ff67bd63b08?, 0xc027b86510?}, 0xc033f77400?, 0x0?)
	github.com/microsoft/typescript-go/internal/lsp/server.go:1177 +0x2b
github.com/microsoft/typescript-go/internal/lsp.init.func1.registerLanguageServiceDocumentRequestHandler[...].29({0x7ff67bd63b08, 0xc027b86510}, 0xc027b036e0)
	github.com/microsoft/typescript-go/internal/lsp/server.go:629 +0x11a
github.com/microsoft/typescript-go/internal/lsp.(*Server).handleRequestOrNotification(0xc0001d0008, {0x7ff67bd63b40?, 0xc027aec0f0?}, 0xc027b036e0)
	github.com/microsoft/typescript-go/internal/lsp/server.go:510 +0x153
github.com/microsoft/typescript-go/internal/lsp.(*Server).dispatchLoop.func1()
	github.com/microsoft/typescript-go/internal/lsp/server.go:413 +0x3a
created by github.com/microsoft/typescript-go/internal/lsp.(*Server).dispatchLoop in goroutine 10
	github.com/microsoft/typescript-go/internal/lsp/server.go:433 +0x9ad

[Error - 1:29:13 PM] Request textDocument/foldingRange failed.
  Message: InternalError: panic handling request textDocument/foldingRange: Token cache mismatch: parent. Expected parent of kind KindArrayLiteralExpression, got KindArrayLiteralExpression
  Code: -32603 ```

eamodio avatar Dec 04 '25 18:12 eamodio

I also hit this, but in https://github.com/jakebailey/pyright-action/blob/main/.ncurc.cjs.

I tried to stick this in a fourslash test, but the fourslash test suite did not seem to like working with a JS file. I might have been holding it wrong.

jakebailey avatar Dec 04 '25 23:12 jakebailey