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

textDocument/codeAction Token cache mismatch: KindCloseBraceToken != KindCommaToken

Open rubnogueira opened this issue 2 weeks ago • 2 comments

Extension Version

0.20251205.1

Stack trace

panic handling request textDocument/codeAction Token cache mismatch: KindCloseBraceToken != KindCommaToken goroutine 176306 [running]:
runtime/debug.Stack()
	runtime/debug/stack.go:26 +0x64
github.com/microsoft/typescript-go/internal/lsp.(*Server).recover(0x140001ce008, 0x140a89e0810)
	github.com/microsoft/typescript-go/internal/lsp/server.go:880 +0x44
panic({0x1053f9060?, 0x140a6b1c5b0?})
	runtime/panic.go:783 +0x120
github.com/microsoft/typescript-go/internal/ast.(*SourceFile).GetOrCreateToken(0x140b2045508, 0x1b, 0x2c5, 0x2c6, 0x140dabe7580)
	github.com/microsoft/typescript-go/internal/ast/ast.go:10954 +0x2fc
github.com/microsoft/typescript-go/internal/ls/change.(*Tracker).InsertNodeInListAfter(0x140a5a7ea80, 0x140b2045508, 0x140b1601260, 0x140b2311760, {0x140ae189200?, 0x104fc06f0?, 0x140e21e09d8?})
	github.com/microsoft/typescript-go/internal/ls/change/tracker.go:350 +0x4d4
github.com/microsoft/typescript-go/internal/ls/change.(*Tracker).InsertImportSpecifierAtIndex(0x140ae189200?, 0x14065277a30?, 0x1?, 0x1?, 0x0?)
	github.com/microsoft/typescript-go/internal/ls/change/tracker.go:378 +0x64
github.com/microsoft/typescript-go/internal/ls.(*LanguageService).doAddExistingFix(0x140a90a5500, 0x140a5a7ea80, 0x140b2045508, 0x140ae189260, 0x0, {0x1401fa75af0, 0x1, 0x0?})
	github.com/microsoft/typescript-go/internal/ls/autoimportfixes.go:146 +0xb24
github.com/microsoft/typescript-go/internal/ls.(*LanguageService).codeActionForFixWorker(0x140a90a5500, {0x105639728?, 0x140a90a5470?}, 0x140a5a7ea80, 0x140b2045508, {0x14033784da1, 0x16}, 0x140a685c800, 0x0)
	github.com/microsoft/typescript-go/internal/ls/autoimports.go:1482 +0x6b4
github.com/microsoft/typescript-go/internal/ls.getImportCodeActions({0x105639728, 0x140a90a5470}, 0x140aa32d980)
	github.com/microsoft/typescript-go/internal/ls/codeactions_importfixes.go:77 +0x18c
github.com/microsoft/typescript-go/internal/ls.(*LanguageService).ProvideCodeActions(0x140a90a5500, {0x105639728, 0x140a90a5470}, 0x140a6806680)
	github.com/microsoft/typescript-go/internal/ls/codeactions.go:85 +0x1f0
github.com/microsoft/typescript-go/internal/lsp.(*Server).handleCodeAction(0x14000792ee8?, {0x105639728?, 0x140a90a5470?}, 0x14097b1d100?, 0x14000792ea8?)
	github.com/microsoft/typescript-go/internal/lsp/server.go:1333 +0x2c
github.com/microsoft/typescript-go/internal/lsp.init.func1.registerLanguageServiceDocumentRequestHandler[...].27({0x105639728, 0x140a90a5470}, 0x140a89e0810)
	github.com/microsoft/typescript-go/internal/lsp/server.go:629 +0xe0
github.com/microsoft/typescript-go/internal/lsp.(*Server).handleRequestOrNotification(0x140001ce008, {0x105639760?, 0x140885b4050?}, 0x140a89e0810)
	github.com/microsoft/typescript-go/internal/lsp/server.go:510 +0x128
github.com/microsoft/typescript-go/internal/lsp.(*Server).dispatchLoop.func1()
	github.com/microsoft/typescript-go/internal/lsp/server.go:413 +0x34
created by github.com/microsoft/typescript-go/internal/lsp.(*Server).dispatchLoop in goroutine 35
	github.com/microsoft/typescript-go/internal/lsp/server.go:433 +0x7a0

[Error - 12:09:58 AM] Request textDocument/codeAction failed.
  Message: InternalError: panic handling request textDocument/codeAction: Token cache mismatch: KindCloseBraceToken != KindCommaToken
  Code: -32603 
panic handling request textDocument/codeAction Token cache mismatch: KindCloseBraceToken != KindCommaToken goroutine 176296 [running]:
runtime/debug.Stack()
	runtime/debug/stack.go:26 +0x64
github.com/microsoft/typescript-go/internal/lsp.(*Server).recover(0x140001ce008, 0x140ab615350)
	github.com/microsoft/typescript-go/internal/lsp/server.go:880 +0x44
panic({0x1053f9060?, 0x140a6eaa9b0?})
	runtime/panic.go:783 +0x120
github.com/microsoft/typescript-go/internal/ast.(*SourceFile).GetOrCreateToken(0x140b2045508, 0x1b, 0x2c5, 0x2c6, 0x140dabe7580)
	github.com/microsoft/typescript-go/internal/ast/ast.go:10954 +0x2fc
github.com/microsoft/typescript-go/internal/ls/change.(*Tracker).InsertNodeInListAfter(0x140a6266070, 0x140b2045508, 0x140b1601260, 0x140186e1970, {0x140ae189200?, 0x104fc06f0?, 0x140c838c558?})
	github.com/microsoft/typescript-go/internal/ls/change/tracker.go:350 +0x4d4
github.com/microsoft/typescript-go/internal/ls/change.(*Tracker).InsertImportSpecifierAtIndex(0x140ae189200?, 0x140a18e7db8?, 0x1?, 0x1?, 0x0?)
	github.com/microsoft/typescript-go/internal/ls/change/tracker.go:378 +0x64
github.com/microsoft/typescript-go/internal/ls.(*LanguageService).doAddExistingFix(0x140a89e0e40, 0x140a6266070, 0x140b2045508, 0x140ae189260, 0x0, {0x14063c27af0, 0x1, 0x0?})
	github.com/microsoft/typescript-go/internal/ls/autoimportfixes.go:146 +0xb24
github.com/microsoft/typescript-go/internal/ls.(*LanguageService).codeActionForFixWorker(0x140a89e0e40, {0x105639728?, 0x140a89e0de0?}, 0x140a6266070, 0x140b2045508, {0x14033784da1, 0x16}, 0x140a737a880, 0x0)
	github.com/microsoft/typescript-go/internal/ls/autoimports.go:1482 +0x6b4
github.com/microsoft/typescript-go/internal/ls.getImportCodeActions({0x105639728, 0x140a89e0de0}, 0x140a68072c0)
	github.com/microsoft/typescript-go/internal/ls/codeactions_importfixes.go:77 +0x18c
github.com/microsoft/typescript-go/internal/ls.(*LanguageService).ProvideCodeActions(0x140a89e0e40, {0x105639728, 0x140a89e0de0}, 0x140a9e4b900)
	github.com/microsoft/typescript-go/internal/ls/codeactions.go:85 +0x1f0
github.com/microsoft/typescript-go/internal/lsp.(*Server).handleCodeAction(0x140039daee8?, {0x105639728?, 0x140a89e0de0?}, 0x140a694aa00?, 0x140039daea8?)
	github.com/microsoft/typescript-go/internal/lsp/server.go:1333 +0x2c
github.com/microsoft/typescript-go/internal/lsp.init.func1.registerLanguageServiceDocumentRequestHandler[...].27({0x105639728, 0x140a89e0de0}, 0x140ab615350)
	github.com/microsoft/typescript-go/internal/lsp/server.go:629 +0xe0
github.com/microsoft/typescript-go/internal/lsp.(*Server).handleRequestOrNotification(0x140001ce008, {0x105639760?, 0x14089cfc140?}, 0x140ab615350)
	github.com/microsoft/typescript-go/internal/lsp/server.go:510 +0x128
github.com/microsoft/typescript-go/internal/lsp.(*Server).dispatchLoop.func1()
	github.com/microsoft/typescript-go/internal/lsp/server.go:413 +0x34
created by github.com/microsoft/typescript-go/internal/lsp.(*Server).dispatchLoop in goroutine 35
	github.com/microsoft/typescript-go/internal/lsp/server.go:433 +0x7a0

[Error - 12:09:58 AM] Request textDocument/codeAction failed.
  Message: InternalError: panic handling request textDocument/codeAction: Token cache mismatch: KindCloseBraceToken != KindCommaToken
  Code: -32603 
panic handling request textDocument/codeAction Token cache mismatch: KindCloseBraceToken != KindCommaToken goroutine 176310 [running]:
runtime/debug.Stack()
	runtime/debug/stack.go:26 +0x64
github.com/microsoft/typescript-go/internal/lsp.(*Server).recover(0x140001ce008, 0x14044a701e0)
	github.com/microsoft/typescript-go/internal/lsp/server.go:880 +0x44
panic({0x1053f9060?, 0x140a8ea5870?})
	runtime/panic.go:783 +0x120
github.com/microsoft/typescript-go/internal/ast.(*SourceFile).GetOrCreateToken(0x140b2045508, 0x1b, 0x2c5, 0x2c6, 0x140dabe7580)
	github.com/microsoft/typescript-go/internal/ast/ast.go:10954 +0x2fc
github.com/microsoft/typescript-go/internal/ls/change.(*Tracker).InsertNodeInListAfter(0x140a67816c0, 0x140b2045508, 0x140b1601260, 0x140b2311970, {0x140ae189200?, 0x104fc06f0?, 0x140eb11fc68?})
	github.com/microsoft/typescript-go/internal/ls/change/tracker.go:350 +0x4d4
github.com/microsoft/typescript-go/internal/ls/change.(*Tracker).InsertImportSpecifierAtIndex(0x140ae189200?, 0x140a137fd08?, 0x1?, 0x1?, 0x0?)
	github.com/microsoft/typescript-go/internal/ls/change/tracker.go:378 +0x64
github.com/microsoft/typescript-go/internal/ls.(*LanguageService).doAddExistingFix(0x140449e1ef0, 0x140a67816c0, 0x140b2045508, 0x140ae189260, 0x0, {0x140935fbaf0, 0x1, 0x0?})
	github.com/microsoft/typescript-go/internal/ls/autoimportfixes.go:146 +0xb24
github.com/microsoft/typescript-go/internal/ls.(*LanguageService).codeActionForFixWorker(0x140449e1ef0, {0x105639728?, 0x140449e1e90?}, 0x140a67816c0, 0x140b2045508, {0x14033784da1, 0x16}, 0x140a6104480, 0x0)
	github.com/microsoft/typescript-go/internal/ls/autoimports.go:1482 +0x6b4
github.com/microsoft/typescript-go/internal/ls.getImportCodeActions({0x105639728, 0x140449e1e90}, 0x140aa800140)
	github.com/microsoft/typescript-go/internal/ls/codeactions_importfixes.go:77 +0x18c
github.com/microsoft/typescript-go/internal/ls.(*LanguageService).ProvideCodeActions(0x140449e1ef0, {0x105639728, 0x140449e1e90}, 0x140ad648840)
	github.com/microsoft/typescript-go/internal/ls/codeactions.go:85 +0x1f0
github.com/microsoft/typescript-go/internal/lsp.(*Server).handleCodeAction(0x14000792ee8?, {0x105639728?, 0x140449e1e90?}, 0x140a694aa00?, 0x14000792ea8?)
	github.com/microsoft/typescript-go/internal/lsp/server.go:1333 +0x2c
github.com/microsoft/typescript-go/internal/lsp.init.func1.registerLanguageServiceDocumentRequestHandler[...].27({0x105639728, 0x140449e1e90}, 0x14044a701e0)
	github.com/microsoft/typescript-go/internal/lsp/server.go:629 +0xe0
github.com/microsoft/typescript-go/internal/lsp.(*Server).handleRequestOrNotification(0x140001ce008, {0x105639760?, 0x140aac91950?}, 0x14044a701e0)
	github.com/microsoft/typescript-go/internal/lsp/server.go:510 +0x128
github.com/microsoft/typescript-go/internal/lsp.(*Server).dispatchLoop.func1()
	github.com/microsoft/typescript-go/internal/lsp/server.go:413 +0x34
created by github.com/microsoft/typescript-go/internal/lsp.(*Server).dispatchLoop in goroutine 35
	github.com/microsoft/typescript-go/internal/lsp/server.go:433 +0x7a0

[Error - 12:09:59 AM] Request textDocument/codeAction failed.
  Message: InternalError: panic handling request textDocument/codeAction: Token cache mismatch: KindCloseBraceToken != KindCommaToken
  Code: -32603 
panic handling request textDocument/codeAction Token cache mismatch: KindCloseBraceToken != KindCommaToken goroutine 176312 [running]:
runtime/debug.Stack()
	runtime/debug/stack.go:26 +0x64
github.com/microsoft/typescript-go/internal/lsp.(*Server).recover(0x140001ce008, 0x14044a70330)
	github.com/microsoft/typescript-go/internal/lsp/server.go:880 +0x44
panic({0x1053f9060?, 0x140a78f5270?})
	runtime/panic.go:783 +0x120
github.com/microsoft/typescript-go/internal/ast.(*SourceFile).GetOrCreateToken(0x140b2045508, 0x1b, 0x2c5, 0x2c6, 0x140dabe7580)
	github.com/microsoft/typescript-go/internal/ast/ast.go:10954 +0x2fc
github.com/microsoft/typescript-go/internal/ls/change.(*Tracker).InsertNodeInListAfter(0x140a67817a0, 0x140b2045508, 0x140b1601260, 0x140b2311b80, {0x140ae189200?, 0x104fc06f0?, 0x140eb11fd88?})
	github.com/microsoft/typescript-go/internal/ls/change/tracker.go:350 +0x4d4
github.com/microsoft/typescript-go/internal/ls/change.(*Tracker).InsertImportSpecifierAtIndex(0x140ae189200?, 0x140a137fef0?, 0x1?, 0x1?, 0x0?)
	github.com/microsoft/typescript-go/internal/ls/change/tracker.go:378 +0x64
github.com/microsoft/typescript-go/internal/ls.(*LanguageService).doAddExistingFix(0x1401516e1e0, 0x140a67817a0, 0x140b2045508, 0x140ae189260, 0x0, {0x140935fbaf0, 0x1, 0x0?})
	github.com/microsoft/typescript-go/internal/ls/autoimportfixes.go:146 +0xb24
github.com/microsoft/typescript-go/internal/ls.(*LanguageService).codeActionForFixWorker(0x1401516e1e0, {0x105639728?, 0x1401516e180?}, 0x140a67817a0, 0x140b2045508, {0x14033784da1, 0x16}, 0x140a6104600, 0x0)
	github.com/microsoft/typescript-go/internal/ls/autoimports.go:1482 +0x6b4
github.com/microsoft/typescript-go/internal/ls.getImportCodeActions({0x105639728, 0x1401516e180}, 0x140aa800440)
	github.com/microsoft/typescript-go/internal/ls/codeactions_importfixes.go:77 +0x18c
github.com/microsoft/typescript-go/internal/ls.(*LanguageService).ProvideCodeActions(0x1401516e1e0, {0x105639728, 0x1401516e180}, 0x140ad648880)
	github.com/microsoft/typescript-go/internal/ls/codeactions.go:85 +0x1f0
github.com/microsoft/typescript-go/internal/lsp.(*Server).handleCodeAction(0x14000792ee8?, {0x105639728?, 0x1401516e180?}, 0x14099b66d00?, 0x14000792ea8?)
	github.com/microsoft/typescript-go/internal/lsp/server.go:1333 +0x2c
github.com/microsoft/typescript-go/internal/lsp.init.func1.registerLanguageServiceDocumentRequestHandler[...].27({0x105639728, 0x1401516e180}, 0x14044a70330)
	github.com/microsoft/typescript-go/internal/lsp/server.go:629 +0xe0
github.com/microsoft/typescript-go/internal/lsp.(*Server).handleRequestOrNotification(0x140001ce008, {0x105639760?, 0x140aac91d60?}, 0x14044a70330)
	github.com/microsoft/typescript-go/internal/lsp/server.go:510 +0x128
github.com/microsoft/typescript-go/internal/lsp.(*Server).dispatchLoop.func1()
	github.com/microsoft/typescript-go/internal/lsp/server.go:413 +0x34
created by github.com/microsoft/typescript-go/internal/lsp.(*Server).dispatchLoop in goroutine 35
	github.com/microsoft/typescript-go/internal/lsp/server.go:433 +0x7a0

[Error - 12:10:00 AM] Request textDocument/codeAction failed.
  Message: InternalError: panic handling request textDocument/codeAction: Token cache mismatch: KindCloseBraceToken != KindCommaToken
  Code: -32603 

Steps to reproduce

  1. While using autocomplete.

rubnogueira avatar Dec 09 '25 00:12 rubnogueira

If you can provide a full repro, this could be super helpful. If not, any chance you'd be able to provide a high-level placeholder of the following?

  1. The function/method you were editing
  2. Any sorts of functions you expected to get auto-imported

DanielRosenwasser avatar Dec 09 '25 02:12 DanielRosenwasser

Unfortunately I don't have a repro and I don't remember how I did it, but I will report here if it happens again.

rubnogueira avatar Dec 09 '25 05:12 rubnogueira

Please open a new issue with repro if you're still seeing this. Thanks!

RyanCavanaugh avatar Dec 16 '25 18:12 RyanCavanaugh