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

Panics when extra closing JSX tag

Open pedro757 opened this issue 1 month ago • 7 comments

Stack trace

[ERROR][2025-11-19 09:44:46] /usr/share/nvim/runtime/lua/vim/lsp/log.lua:151	"rpc"	"tsgo"	"stderr"	"panic handling request textDocument/completion interface conversion: ast.nodeData is *ast.Token, not *ast.Identifier goroutine 164406 [running]:\nruntime/debug.Stack()\n\truntime/debug/stack.go:26 +0x5e\ngithub.com/microsoft/typescript-go/internal/lsp.(*Server).recover(0xc000238008, 0xc07b817380)\n\tgithub.com/microsoft/typescript-go/internal/lsp/server.go:572 +0x58\npanic({0xb82b40?, 0xc01bba1e30?})\n\truntime/panic.go:783 +0x132\ngithub.com/microsoft/typescript-go/internal/ast.(*Node).AsIdentifier(...)\n\tgithub.com/microsoft/typescript-go/internal/ast/ast.go:1203\ngithub.com/microsoft/typescript-go/internal/ls.tryGetObjectTypeDeclarationCompletionContainer(0xc07cc5c308, 0xc07ce661e0, 0xc07ce66210, 0x10ea1)\n\tgithub.com/microsoft/typescript-go/internal/ls/completions.go:4092 +0x4f1\ngithub.com/microsoft/typescript-go/internal/ls.(*LanguageService).getCompletionData.func15()\n\tgithub.com/microsoft/typescript-go/internal/ls/completions.go:1445 +0x8f\ngithub.com/microsoft/typescript-go/internal/ls.(*LanguageService).getCompletionData.func18(...)\n\tgithub.com/microsoft/typescript-go/internal/ls/completions.go:1696\ngithub.com/microsoft/typescript-go/internal/ls.(*LanguageService).getCompletionData(0xc07ce45380, {0xef1228, 0xc05d277260}, 0xc0112a0c08, 0xc07cc5c308, 0x10ea1, 0xc02758c960)\n\tgithub.com/microsoft/typescript-go/internal/ls/completions.go:1724 +0x1edf\ngithub.com/microsoft/typescript-go/internal/ls.(*LanguageService).getCompletionsAtPosition(0xc07ce45380, {0xef1228, 0xc05d277260}, 0xc07cc5c308, 0x10ea1, 0x0)\n\tgithub.com/microsoft/typescript-go/internal/ls/completions.go:390 +0x2cf\ngithub.com/microsoft/typescript-go/internal/ls.(*LanguageService).ProvideCompletion(0xc07ce45380, {0xef1228, 0xc05d277260}, {0xc06f320af0?, 0x0?}, {0x400?, 0x50000?}, 0xc07b65f2d0)\n\tgithub.com/microsoft/typescript-go/internal/ls/completions.go:46 +0xc9\ngithub.com/microsoft/typescript-go/internal/lsp.(*Server).handleCompletion(0xc00027cb40?, {0xef1228?, 0xc05d277260?}, 0xc06f320af0?, 0x69?)\n\tgithub.com/microsoft/typescript-go/internal/lsp/server.go:878 +0x39\ngithub.com/microsoft/typescript-go/internal/lsp.init.func1.registerLanguageServiceDocumentRequestHandler[...].16({0xef1228, 0xc05d277260}, 0xc07b817380)\n\tgithub.com/microsoft/typescript-go/internal/lsp/server.go:558 +0x130\ngithub.com/microsoft/typescript-go/internal/lsp.(*Server).handleRequestOrNotification(0xc000238008, {0xef1260?, 0xc05d3324b0?}, 0xc07b817380)\n\tgithub.com/microsoft/typescript-go/internal/lsp/server.go:451 +0x153\ngithub.com/microsoft/typescript-go/internal/lsp.(*Server).dispatchLoop.func1()\n\tgithub.com/microsoft/typescript-go/internal/lsp/server.go:354 +0x3a\ncreated by github.com/microsoft/typescript-go/internal/lsp.(*Server).dispatchLoop in goroutine 34\n\tgithub.com/microsoft/typescript-go/internal/lsp/server.go:374 +0x9ad\n\n"
[ERROR][2025-11-19 09:44:47] /usr/share/nvim/runtime/lua/vim/lsp/log.lua:151	"rpc"	"tsgo"	"stderr"	"panic handling request textDocument/documentHighlight interface conversion: ast.nodeData is *ast.Token, not *ast.Identifier goroutine 164368 [running]:\nruntime/debug.Stack()\n\truntime/debug/stack.go:26 +0x5e\ngithub.com/microsoft/typescript-go/internal/lsp.(*Server).recover(0xc000238008, 0xc084d0c060)\n\tgithub.com/microsoft/typescript-go/internal/lsp/server.go:572 +0x58\npanic({0xb82b40?, 0xc01abba510?})\n\truntime/panic.go:783 +0x132\ngithub.com/microsoft/typescript-go/internal/ast.(*Node).AsIdentifier(...)\n\tgithub.com/microsoft/typescript-go/internal/ast/ast.go:1203\ngithub.com/microsoft/typescript-go/internal/ast.(*Node).Text(0xb96bc0?)\n\tgithub.com/microsoft/typescript-go/internal/ast/ast.go:306 +0x4df\ngithub.com/microsoft/typescript-go/internal/ls.isThis(...)\n\tgithub.com/microsoft/typescript-go/internal/ls/utilities.go:371\ngithub.com/microsoft/typescript-go/internal/ls.getReferencedSymbolsSpecial(0xc084a3e5d0, {0xc084a20398, 0x1, 0x1})\n\tgithub.com/microsoft/typescript-go/internal/ls/findallreferences.go:808 +0x2a8\ngithub.com/microsoft/typescript-go/internal/ls.(*LanguageService).getReferencedSymbolsForNode(0xc084a3e4b0, {0xef1228, 0xc084a3e450}, 0x10ea2, 0xc084a3e5d0, 0xc08207e000, {0xc084a20398, 0x1, 0x1}, {0x0, ...}, ...)\n\tgithub.com/microsoft/typescript-go/internal/ls/findallreferences.go:696 +0x571\ngithub.com/microsoft/typescript-go/internal/ls.(*LanguageService).getSemanticDocumentHighlights(0xc084a3e4b0, {0xef1228, 0xc084a3e450}, 0x10ea2, 0xc084a3e5d0, 0xc08207e000, 0xc043ef2908)\n\tgithub.com/microsoft/typescript-go/internal/ls/documenthighlights.go:55 +0x105\ngithub.com/microsoft/typescript-go/internal/ls.(*LanguageService).ProvideDocumentHighlights(0xc084a3e4b0, {0xef1228, 0xc084a3e450}, {0xc068c24070?, 0x30?}, {0x1bc008?, 0xc0?})\n\tgithub.com/microsoft/typescript-go/internal/ls/documenthighlights.go:45 +0x3be\ngithub.com/microsoft/typescript-go/internal/lsp.(*Server).handleDocumentHighlight(0xc00027cb40?, {0xef1228?, 0xc084a3e450?}, 0xc068c24070?, 0x69?)\n\tgithub.com/microsoft/typescript-go/internal/lsp/server.go:947 +0x35\ngithub.com/microsoft/typescript-go/internal/lsp.init.func1.registerLanguageServiceDocumentRequestHandler[...].25({0xef1228, 0xc084a3e450}, 0xc084d0c060)\n\tgithub.com/microsoft/typescript-go/internal/lsp/server.go:558 +0x11a\ngithub.com/microsoft/typescript-go/internal/lsp.(*Server).handleRequestOrNotification(0xc000238008, {0xef1260?, 0xc0848d8d70?}, 0xc084d0c060)\n\tgithub.com/microsoft/typescript-go/internal/lsp/server.go:451 +0x153\ngithub.com/microsoft/typescript-go/internal/lsp.(*Server).dispatchLoop.func1()\n\tgithub.com/microsoft/typescript-go/internal/lsp/server.go:354 +0x3a\ncreated by github.com/microsoft/typescript-go/internal/lsp.(*Server).dispatchLoop in goroutine 34\n\tgithub.com/microsoft/typescript-go/internal/lsp/server.go:374 +0x9ad\n\n"
[ERROR][2025-11-19 09:44:47] /usr/share/nvim/runtime/lua/vim/lsp/log.lua:151	"rpc"	"tsgo"	"stderr"	"panic handling request textDocument/completion interface conversion: ast.nodeData is *ast.Token, not *ast.Identifier goroutine 164352 [running]:\nruntime/debug.Stack()\n\truntime/debug/stack.go:26 +0x5e\ngithub.com/microsoft/typescript-go/internal/lsp.(*Server).recover(0xc000238008, 0xc01abba390)\n\tgithub.com/microsoft/typescript-go/internal/lsp/server.go:572 +0x58\npanic({0xb82b40?, 0xc01abbbf20?})\n\truntime/panic.go:783 +0x132\ngithub.com/microsoft/typescript-go/internal/ast.(*Node).AsIdentifier(...)\n\tgithub.com/microsoft/typescript-go/internal/ast/ast.go:1203\ngithub.com/microsoft/typescript-go/internal/ls.tryGetObjectTypeDeclarationCompletionContainer(0xc043ef2908, 0xc0162911d0, 0xc084a3e5d0, 0x10ea2)\n\tgithub.com/microsoft/typescript-go/internal/ls/completions.go:4092 +0x4f1\ngithub.com/microsoft/typescript-go/internal/ls.(*LanguageService).getCompletionData.func15()\n\tgithub.com/microsoft/typescript-go/internal/ls/completions.go:1445 +0x8f\ngithub.com/microsoft/typescript-go/internal/ls.(*LanguageService).getCompletionData.func18(...)\n\tgithub.com/microsoft/typescript-go/internal/ls/completions.go:1696\ngithub.com/microsoft/typescript-go/internal/ls.(*LanguageService).getCompletionData(0xc06d62d530, {0xef1228, 0xc06d62d470}, 0xc081f2cc08, 0xc043ef2908, 0x10ea2, 0xc02758c960)\n\tgithub.com/microsoft/typescript-go/internal/ls/completions.go:1724 +0x1edf\ngithub.com/microsoft/typescript-go/internal/ls.(*LanguageService).getCompletionsAtPosition(0xc06d62d530, {0xef1228, 0xc06d62d470}, 0xc043ef2908, 0x10ea2, 0x0)\n\tgithub.com/microsoft/typescript-go/internal/ls/completions.go:390 +0x2cf\ngithub.com/microsoft/typescript-go/internal/ls.(*LanguageService).ProvideCompletion(0xc06d62d530, {0xef1228, 0xc06d62d470}, {0xc071edc000?, 0x4f0016?}, {0x400?, 0x50000?}, 0xc06b2d6690)\n\tgithub.com/microsoft/typescript-go/internal/ls/completions.go:46 +0xc9\ngithub.com/microsoft/typescript-go/internal/lsp.(*Server).handleCompletion(0xc00027cb40?, {0xef1228?, 0xc06d62d470?}, 0xc071edc000?, 0x69?)\n\tgithub.com/microsoft/typescript-go/internal/lsp/server.go:878 +0x39\ngithub.com/microsoft/typescript-go/internal/lsp.init.func1.registerLanguageServiceDocumentRequestHandler[...].16({0xef1228, 0xc06d62d470}, 0xc01abba390)\n\tgithub.com/microsoft/typescript-go/internal/lsp/server.go:558 +0x130\ngithub.com/microsoft/typescript-go/internal/lsp.(*Server).handleRequestOrNotification(0xc000238008, {0xef1260?, 0xc067260460?}, 0xc01abba390)\n\tgithub.com/microsoft/typescript-go/internal/lsp/server.go:451 +0x153\ngithub.com/microsoft/typescript-go/internal/lsp.(*Server).dispatchLoop.func1()\n\tgithub.com/microsoft/typescript-go/internal/lsp/server.go:354 +0x3a\ncreated by github.com/microsoft/typescript-go/internal/lsp.(*Server).dispatchLoop in goroutine 34\n\tgithub.com/microsoft/typescript-go/internal/lsp/server.go:374 +0x9ad\n\n"

Steps to reproduce

  1. I copied an extra closing tag and pasted it.
  2. It started showing errors until deleting the extra closing tag

pedro757 avatar Nov 19 '25 13:11 pedro757

I think we need more of a repro than that, unfortunately

jakebailey avatar Nov 19 '25 16:11 jakebailey

@jakebailey Hope this helps.

[ERROR][2025-11-20 09:40:56] /usr/share/nvim/runtime/lua/vim/lsp/log.lua:151	"rpc"	"tsgo"	"stderr"	"panic handling request textDocument/documentHighlight interface conversion: ast.nodeData is *ast.Token, not *ast.Identifier goroutine 360382 [running]:\nruntime/debug.Stack()\n\truntime/debug/stack.go:26 +0x5e\ngithub.com/microsoft/typescript-go/internal/lsp.(*Server).recover(0xc000138608, 0xc04efb0990)\n\tgithub.com/microsoft/typescript-go/internal/lsp/server.go:572 +0x58\npanic({0xb82b40?, 0xc04ea389c0?})\n\truntime/panic.go:783 +0x132\ngithub.com/microsoft/typescript-go/internal/ast.(*Node).AsIdentifier(...)\n\tgithub.com/microsoft/typescript-go/internal/ast/ast.go:1203\ngithub.com/microsoft/typescript-go/internal/ast.(*Node).Text(0xb96bc0?)\n\tgithub.com/microsoft/typescript-go/internal/ast/ast.go:306 +0x4df\ngithub.com/microsoft/typescript-go/internal/ls.isThis(...)\n\tgithub.com/microsoft/typescript-go/internal/ls/utilities.go:371\ngithub.com/microsoft/typescript-go/internal/ls.getReferencedSymbolsSpecial(0xc04ea38930, {0xc04555fa70, 0x1, 0x1})\n\tgithub.com/microsoft/typescript-go/internal/ls/findallreferences.go:808 +0x2a8\ngithub.com/microsoft/typescript-go/internal/ls.(*LanguageService).getReferencedSymbolsForNode(0xc04ea38840, {0xef1228, 0xc04ea387e0}, 0x1bd0, 0xc04ea38930, 0xc031255500, {0xc04555fa70, 0x1, 0x1}, {0x0, ...}, ...)\n\tgithub.com/microsoft/typescript-go/internal/ls/findallreferences.go:696 +0x571\ngithub.com/microsoft/typescript-go/internal/ls.(*LanguageService).getSemanticDocumentHighlights(0xc04ea38840, {0xef1228, 0xc04ea387e0}, 0x1bd0, 0xc04ea38930, 0xc031255500, 0xc02b056908)\n\tgithub.com/microsoft/typescript-go/internal/ls/documenthighlights.go:55 +0x105\ngithub.com/microsoft/typescript-go/internal/ls.(*LanguageService).ProvideDocumentHighlights(0xc04ea38840, {0xef1228, 0xc04ea387e0}, {0xc05cc40300?, 0x30?}, {0x7e808?, 0xc0?})\n\tgithub.com/microsoft/typescript-go/internal/ls/documenthighlights.go:45 +0x3be\ngithub.com/microsoft/typescript-go/internal/lsp.(*Server).handleDocumentHighlight(0xc0002bcb40?, {0xef1228?, 0xc04ea387e0?}, 0xc05cc40300?, 0x60?)\n\tgithub.com/microsoft/typescript-go/internal/lsp/server.go:947 +0x35\ngithub.com/microsoft/typescript-go/internal/lsp.init.func1.registerLanguageServiceDocumentRequestHandler[...].25({0xef1228, 0xc04ea387e0}, 0xc04efb0990)\n\tgithub.com/microsoft/typescript-go/internal/lsp/server.go:558 +0x11a\ngithub.com/microsoft/typescript-go/internal/lsp.(*Server).handleRequestOrNotification(0xc000138608, {0xef1260?, 0xc042ba9270?}, 0xc04efb0990)\n\tgithub.com/microsoft/typescript-go/internal/lsp/server.go:451 +0x153\ngithub.com/microsoft/typescript-go/internal/lsp.(*Server).dispatchLoop.func1()\n\tgithub.com/microsoft/typescript-go/internal/lsp/server.go:354 +0x3a\ncreated by github.com/microsoft/typescript-go/internal/lsp.(*Server).dispatchLoop in goroutine 35\n\tgithub.com/microsoft/typescript-go/internal/lsp/server.go:374 +0x9ad\n\n"
[ERROR][2025-11-20 09:40:58] /usr/share/nvim/runtime/lua/vim/lsp/log.lua:151	"rpc"	"tsgo"	"stderr"	"panic handling request textDocument/documentHighlight did not expect KindJsxElement to have KindIdentifier in its trivia goroutine 359917 [running]:\nruntime/debug.Stack()\n\truntime/debug/stack.go:26 +0x5e\ngithub.com/microsoft/typescript-go/internal/lsp.(*Server).recover(0xc000138608, 0xc04efb09f0)\n\tgithub.com/microsoft/typescript-go/internal/lsp/server.go:572 +0x58\npanic({0xb46f40?, 0xc045d366e0?})\n\truntime/panic.go:783 +0x132\ngithub.com/microsoft/typescript-go/internal/astnav.getTokenAtPosition(0xc02b056908, 0x1bcf, 0x0, 0xdc9318)\n\tgithub.com/microsoft/typescript-go/internal/astnav/tokens.go:195 +0x5f9\ngithub.com/microsoft/typescript-go/internal/astnav.GetTouchingPropertyName(0xc03f85c828?, 0xeeec70?)\n\tgithub.com/microsoft/typescript-go/internal/astnav/tokens.go:12 +0x1c\ngithub.com/microsoft/typescript-go/internal/ls.(*LanguageService).ProvideDocumentHighlights(0xc04efb0b70, {0xef1228, 0xc04efb0b10}, {0xc03e6387e0?, 0x30?}, {0x601808?, 0xc0?})\n\tgithub.com/microsoft/typescript-go/internal/ls/documenthighlights.go:20 +0x8e\ngithub.com/microsoft/typescript-go/internal/lsp.(*Server).handleDocumentHighlight(0xc0002bcb40?, {0xef1228?, 0xc04efb0b10?}, 0xc03e6387e0?, 0x60?)\n\tgithub.com/microsoft/typescript-go/internal/lsp/server.go:947 +0x35\ngithub.com/microsoft/typescript-go/internal/lsp.init.func1.registerLanguageServiceDocumentRequestHandler[...].25({0xef1228, 0xc04efb0b10}, 0xc04efb09f0)\n\tgithub.com/microsoft/typescript-go/internal/lsp/server.go:558 +0x11a\ngithub.com/microsoft/typescript-go/internal/lsp.(*Server).handleRequestOrNotification(0xc000138608, {0xef1260?, 0xc041a64320?}, 0xc04efb09f0)\n\tgithub.com/microsoft/typescript-go/internal/lsp/server.go:451 +0x153\ngithub.com/microsoft/typescript-go/internal/lsp.(*Server).dispatchLoop.func1()\n\tgithub.com/microsoft/typescript-go/internal/lsp/server.go:354 +0x3a\ncreated by github.com/microsoft/typescript-go/internal/lsp.(*Server).dispatchLoop in goroutine 35\n\tgithub.com/microsoft/typescript-go/internal/lsp/server.go:374 +0x9ad\n\n"

https://github.com/user-attachments/assets/807ec25b-dc7a-499b-96d2-5a27399477ef

As you can see I'm using AI suggestions but it panicked before I can accept closing tag suggestion.

              <Button
                className="mt-4 w-full"
                onClick={() => {
                  void router.push("/admin/new-sub");
                }}
              >
                Crear subscripción
// CRASHES 

I don't know if it's the same error I described above, I copied the logs anyway.

Let me know if you need anything else.

pedro757 avatar Nov 20 '25 13:11 pedro757

@jakebailey Look at this other example, deleting a closing tag, it starts panicking everywhere.

[ERROR][2025-11-20 10:05:07] /usr/share/nvim/runtime/lua/vim/lsp/log.lua:151	"rpc"	"tsgo"	"stderr"	"panic handling request textDocument/documentHighlight did not expect KindJsxElement to have KindIdentifier in its trivia goroutine 426559 [running]:\nruntime/debug.Stack()\n\truntime/debug/stack.go:26 +0x5e\ngithub.com/microsoft/typescript-go/internal/lsp.(*Server).recover(0xc000138608, 0xc066b77260)\n\tgithub.com/microsoft/typescript-go/internal/lsp/server.go:572 +0x58\npanic({0xb46f40?, 0xc06c844560?})\n\truntime/panic.go:783 +0x132\ngithub.com/microsoft/typescript-go/internal/astnav.getTokenAtPosition(0xc056148c08, 0x1c7a, 0x0, 0xdc9318)\n\tgithub.com/microsoft/typescript-go/internal/astnav/tokens.go:195 +0x5f9\ngithub.com/microsoft/typescript-go/internal/astnav.GetTouchingPropertyName(0xc014c900d8?, 0xeeec70?)\n\tgithub.com/microsoft/typescript-go/internal/astnav/tokens.go:12 +0x1c\ngithub.com/microsoft/typescript-go/internal/ls.(*LanguageService).ProvideDocumentHighlights(0xc0572445a0, {0xef1228, 0xc0572444e0}, {0xc0233e9b60?, 0x30?}, {0x1f2008?, 0xc0?})\n\tgithub.com/microsoft/typescript-go/internal/ls/documenthighlights.go:20 +0x8e\ngithub.com/microsoft/typescript-go/internal/lsp.(*Server).handleDocumentHighlight(0xc0002bcb40?, {0xef1228?, 0xc0572444e0?}, 0xc0233e9b60?, 0x60?)\n\tgithub.com/microsoft/typescript-go/internal/lsp/server.go:947 +0x35\ngithub.com/microsoft/typescript-go/internal/lsp.init.func1.registerLanguageServiceDocumentRequestHandler[...].25({0xef1228, 0xc0572444e0}, 0xc066b77260)\n\tgithub.com/microsoft/typescript-go/internal/lsp/server.go:558 +0x11a\ngithub.com/microsoft/typescript-go/internal/lsp.(*Server).handleRequestOrNotification(0xc000138608, {0xef1260?, 0xc03fed8050?}, 0xc066b77260)\n\tgithub.com/microsoft/typescript-go/internal/lsp/server.go:451 +0x153\ngithub.com/microsoft/typescript-go/internal/lsp.(*Server).dispatchLoop.func1()\n\tgithub.com/microsoft/typescript-go/internal/lsp/server.go:354 +0x3a\ncreated by github.com/microsoft/typescript-go/internal/lsp.(*Server).dispatchLoop in goroutine 35\n\tgithub.com/microsoft/typescript-go/internal/lsp/server.go:374 +0x9ad\n\n"
[ERROR][2025-11-20 10:05:08] /usr/share/nvim/runtime/lua/vim/lsp/log.lua:151	"rpc"	"tsgo"	"stderr"	"panic handling request textDocument/documentHighlight did not expect KindJsxElement to have KindIdentifier in its trivia goroutine 426560 [running]:\nruntime/debug.Stack()\n\truntime/debug/stack.go:26 +0x5e\ngithub.com/microsoft/typescript-go/internal/lsp.(*Server).recover(0xc000138608, 0xc066b772c0)\n\tgithub.com/microsoft/typescript-go/internal/lsp/server.go:572 +0x58\npanic({0xb46f40?, 0xc06c844830?})\n\truntime/panic.go:783 +0x132\ngithub.com/microsoft/typescript-go/internal/astnav.getTokenAtPosition(0xc056148c08, 0x1c45, 0x0, 0xdc9318)\n\tgithub.com/microsoft/typescript-go/internal/astnav/tokens.go:195 +0x5f9\ngithub.com/microsoft/typescript-go/internal/astnav.GetTouchingPropertyName(0xc014c900d8?, 0xeeec70?)\n\tgithub.com/microsoft/typescript-go/internal/astnav/tokens.go:12 +0x1c\ngithub.com/microsoft/typescript-go/internal/ls.(*LanguageService).ProvideDocumentHighlights(0xc0572448d0, {0xef1228, 0xc057244840}, {0xc00c35cde0?, 0x30?}, {0x1f2008?, 0xc0?})\n\tgithub.com/microsoft/typescript-go/internal/ls/documenthighlights.go:20 +0x8e\ngithub.com/microsoft/typescript-go/internal/lsp.(*Server).handleDocumentHighlight(0xc0002bcb40?, {0xef1228?, 0xc057244840?}, 0xc00c35cde0?, 0x60?)\n\tgithub.com/microsoft/typescript-go/internal/lsp/server.go:947 +0x35\ngithub.com/microsoft/typescript-go/internal/lsp.init.func1.registerLanguageServiceDocumentRequestHandler[...].25({0xef1228, 0xc057244840}, 0xc066b772c0)\n\tgithub.com/microsoft/typescript-go/internal/lsp/server.go:558 +0x11a\ngithub.com/microsoft/typescript-go/internal/lsp.(*Server).handleRequestOrNotification(0xc000138608, {0xef1260?, 0xc03fed8320?}, 0xc066b772c0)\n\tgithub.com/microsoft/typescript-go/internal/lsp/server.go:451 +0x153\ngithub.com/microsoft/typescript-go/internal/lsp.(*Server).dispatchLoop.func1()\n\tgithub.com/microsoft/typescript-go/internal/lsp/server.go:354 +0x3a\ncreated by github.com/microsoft/typescript-go/internal/lsp.(*Server).dispatchLoop in goroutine 35\n\tgithub.com/microsoft/typescript-go/internal/lsp/server.go:374 +0x9ad\n\n"
[ERROR][2025-11-20 10:05:08] /usr/share/nvim/runtime/lua/vim/lsp/log.lua:151	"rpc"	"tsgo"	"stderr"	"panic handling request textDocument/documentHighlight did not expect KindJsxElement to have KindIdentifier in its trivia goroutine 426594 [running]:\nruntime/debug.Stack()\n\truntime/debug/stack.go:26 +0x5e\ngithub.com/microsoft/typescript-go/internal/lsp.(*Server).recover(0xc000138608, 0xc066b77380)\n\tgithub.com/microsoft/typescript-go/internal/lsp/server.go:572 +0x58\npanic({0xb46f40?, 0xc06c844d60?})\n\truntime/panic.go:783 +0x132\ngithub.com/microsoft/typescript-go/internal/astnav.getTokenAtPosition(0xc056148c08, 0x1c11, 0x0, 0xdc9318)\n\tgithub.com/microsoft/typescript-go/internal/astnav/tokens.go:195 +0x5f9\ngithub.com/microsoft/typescript-go/internal/astnav.GetTouchingPropertyName(0xc014c900d8?, 0xeeec70?)\n\tgithub.com/microsoft/typescript-go/internal/astnav/tokens.go:12 +0x1c\ngithub.com/microsoft/typescript-go/internal/ls.(*LanguageService).ProvideDocumentHighlights(0xc057245080, {0xef1228, 0xc057245020}, {0xc0233e9b60?, 0x30?}, {0x1f2008?, 0xc0?})\n\tgithub.com/microsoft/typescript-go/internal/ls/documenthighlights.go:20 +0x8e\ngithub.com/microsoft/typescript-go/internal/lsp.(*Server).handleDocumentHighlight(0xc0002bcb40?, {0xef1228?, 0xc057245020?}, 0xc0233e9b60?, 0x60?)\n\tgithub.com/microsoft/typescript-go/internal/lsp/server.go:947 +0x35\ngithub.com/microsoft/typescript-go/internal/lsp.init.func1.registerLanguageServiceDocumentRequestHandler[...].25({0xef1228, 0xc057245020}, 0xc066b77380)\n\tgithub.com/microsoft/typescript-go/internal/lsp/server.go:558 +0x11a\ngithub.com/microsoft/typescript-go/internal/lsp.(*Server).handleRequestOrNotification(0xc000138608, {0xef1260?, 0xc03fed8460?}, 0xc066b77380)\n\tgithub.com/microsoft/typescript-go/internal/lsp/server.go:451 +0x153\ngithub.com/microsoft/typescript-go/internal/lsp.(*Server).dispatchLoop.func1()\n\tgithub.com/microsoft/typescript-go/internal/lsp/server.go:354 +0x3a\ncreated by github.com/microsoft/typescript-go/internal/lsp.(*Server).dispatchLoop in goroutine 35\n\tgithub.com/microsoft/typescript-go/internal/lsp/server.go:374 +0x9ad\n\n"
[ERROR][2025-11-20 10:05:09] /usr/share/nvim/runtime/lua/vim/lsp/log.lua:151	"rpc"	"tsgo"	"stderr"	"panic handling request textDocument/documentHighlight did not expect KindJsxElement to have KindIdentifier in its trivia goroutine 426595 [running]:\nruntime/debug.Stack()\n\truntime/debug/stack.go:26 +0x5e\ngithub.com/microsoft/typescript-go/internal/lsp.(*Server).recover(0xc000138608, 0xc066b773e0)\n\tgithub.com/microsoft/typescript-go/internal/lsp/server.go:572 +0x58\npanic({0xb46f40?, 0xc06c845040?})\n\truntime/panic.go:783 +0x132\ngithub.com/microsoft/typescript-go/internal/astnav.getTokenAtPosition(0xc056148c08, 0x1bf5, 0x0, 0xdc9318)\n\tgithub.com/microsoft/typescript-go/internal/astnav/tokens.go:195 +0x5f9\ngithub.com/microsoft/typescript-go/internal/astnav.GetTouchingPropertyName(0xc014c900d8?, 0xeeec70?)\n\tgithub.com/microsoft/typescript-go/internal/astnav/tokens.go:12 +0x1c\ngithub.com/microsoft/typescript-go/internal/ls.(*LanguageService).ProvideDocumentHighlights(0xc057245350, {0xef1228, 0xc0572452f0}, {0xc00c35cde0?, 0x30?}, {0x600008?, 0xc0?})\n\tgithub.com/microsoft/typescript-go/internal/ls/documenthighlights.go:20 +0x8e\ngithub.com/microsoft/typescript-go/internal/lsp.(*Server).handleDocumentHighlight(0xc0002bcb40?, {0xef1228?, 0xc0572452f0?}, 0xc00c35cde0?, 0x60?)\n\tgithub.com/microsoft/typescript-go/internal/lsp/server.go:947 +0x35\ngithub.com/microsoft/typescript-go/internal/lsp.init.func1.registerLanguageServiceDocumentRequestHandler[...].25({0xef1228, 0xc0572452f0}, 0xc066b773e0)\n\tgithub.com/microsoft/typescript-go/internal/lsp/server.go:558 +0x11a\ngithub.com/microsoft/typescript-go/internal/lsp.(*Server).handleRequestOrNotification(0xc000138608, {0xef1260?, 0xc03fed84b0?}, 0xc066b773e0)\n\tgithub.com/microsoft/typescript-go/internal/lsp/server.go:451 +0x153\ngithub.com/microsoft/typescript-go/internal/lsp.(*Server).dispatchLoop.func1()\n\tgithub.com/microsoft/typescript-go/internal/lsp/server.go:354 +0x3a\ncreated by github.com/microsoft/typescript-go/internal/lsp.(*Server).dispatchLoop in goroutine 35\n\tgithub.com/microsoft/typescript-go/internal/lsp/server.go:374 +0x9ad\n\n"

https://github.com/user-attachments/assets/17ff3e69-e447-484c-b91a-7e642f51b8d5

In this case I just deleted a closing tag </div> and it panics everywhere after that.

I believe all of these are the same error, related to JSX tag not being fully closed

pedro757 avatar Nov 20 '25 14:11 pedro757

I provided two videos showing the error @RyanCavanaugh @jakebailey If you need me to provide more info, let me know

pedro757 avatar Nov 20 '25 14:11 pedro757

These are the crashes from the main issue. They are two different crashes.

panic handling request textDocument/completion interface conversion: ast.nodeData is *ast.Token, not *ast.Identifier goroutine 164406 [running]:
runtime/debug.Stack()
	runtime/debug/stack.go:26 +0x5e
github.com/microsoft/typescript-go/internal/lsp.(*Server).recover(0xc000238008, 0xc07b817380)
	github.com/microsoft/typescript-go/internal/lsp/server.go:572 +0x58
panic({0xb82b40?, 0xc01bba1e30?})
	runtime/panic.go:783 +0x132
github.com/microsoft/typescript-go/internal/ast.(*Node).AsIdentifier(...)
	github.com/microsoft/typescript-go/internal/ast/ast.go:1203
github.com/microsoft/typescript-go/internal/ls.tryGetObjectTypeDeclarationCompletionContainer(0xc07cc5c308, 0xc07ce661e0, 0xc07ce66210, 0x10ea1)
	github.com/microsoft/typescript-go/internal/ls/completions.go:4092 +0x4f1
github.com/microsoft/typescript-go/internal/ls.(*LanguageService).getCompletionData.func15()
	github.com/microsoft/typescript-go/internal/ls/completions.go:1445 +0x8f
github.com/microsoft/typescript-go/internal/ls.(*LanguageService).getCompletionData.func18(...)
	github.com/microsoft/typescript-go/internal/ls/completions.go:1696
github.com/microsoft/typescript-go/internal/ls.(*LanguageService).getCompletionData(0xc07ce45380, {0xef1228, 0xc05d277260}, 0xc0112a0c08, 0xc07cc5c308, 0x10ea1, 0xc02758c960)
	github.com/microsoft/typescript-go/internal/ls/completions.go:1724 +0x1edf
github.com/microsoft/typescript-go/internal/ls.(*LanguageService).getCompletionsAtPosition(0xc07ce45380, {0xef1228, 0xc05d277260}, 0xc07cc5c308, 0x10ea1, 0x0)
	github.com/microsoft/typescript-go/internal/ls/completions.go:390 +0x2cf
github.com/microsoft/typescript-go/internal/ls.(*LanguageService).ProvideCompletion(0xc07ce45380, {0xef1228, 0xc05d277260}, {0xc06f320af0?, 0x0?}, {0x400?, 0x50000?}, 0xc07b65f2d0)
	github.com/microsoft/typescript-go/internal/ls/completions.go:46 +0xc9
github.com/microsoft/typescript-go/internal/lsp.(*Server).handleCompletion(0xc00027cb40?, {0xef1228?, 0xc05d277260?}, 0xc06f320af0?, 0x69?)
	github.com/microsoft/typescript-go/internal/lsp/server.go:878 +0x39
github.com/microsoft/typescript-go/internal/lsp.init.func1.registerLanguageServiceDocumentRequestHandler[...].16({0xef1228, 0xc05d277260}, 0xc07b817380)
	github.com/microsoft/typescript-go/internal/lsp/server.go:558 +0x130
github.com/microsoft/typescript-go/internal/lsp.(*Server).handleRequestOrNotification(0xc000238008, {0xef1260?, 0xc05d3324b0?}, 0xc07b817380)
	github.com/microsoft/typescript-go/internal/lsp/server.go:451 +0x153
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 34
	github.com/microsoft/typescript-go/internal/lsp/server.go:374 +0x9ad
panic handling request textDocument/documentHighlight interface conversion: ast.nodeData is *ast.Token, not *ast.Identifier goroutine 164368 [running]:
runtime/debug.Stack()
	runtime/debug/stack.go:26 +0x5e
github.com/microsoft/typescript-go/internal/lsp.(*Server).recover(0xc000238008, 0xc084d0c060)
	github.com/microsoft/typescript-go/internal/lsp/server.go:572 +0x58
panic({0xb82b40?, 0xc01abba510?})
	runtime/panic.go:783 +0x132
github.com/microsoft/typescript-go/internal/ast.(*Node).AsIdentifier(...)
	github.com/microsoft/typescript-go/internal/ast/ast.go:1203
github.com/microsoft/typescript-go/internal/ast.(*Node).Text(0xb96bc0?)
	github.com/microsoft/typescript-go/internal/ast/ast.go:306 +0x4df
github.com/microsoft/typescript-go/internal/ls.isThis(...)
	github.com/microsoft/typescript-go/internal/ls/utilities.go:371
github.com/microsoft/typescript-go/internal/ls.getReferencedSymbolsSpecial(0xc084a3e5d0, {0xc084a20398, 0x1, 0x1})
	github.com/microsoft/typescript-go/internal/ls/findallreferences.go:808 +0x2a8
github.com/microsoft/typescript-go/internal/ls.(*LanguageService).getReferencedSymbolsForNode(0xc084a3e4b0, {0xef1228, 0xc084a3e450}, 0x10ea2, 0xc084a3e5d0, 0xc08207e000, {0xc084a20398, 0x1, 0x1}, {0x0, ...}, ...)
	github.com/microsoft/typescript-go/internal/ls/findallreferences.go:696 +0x571
github.com/microsoft/typescript-go/internal/ls.(*LanguageService).getSemanticDocumentHighlights(0xc084a3e4b0, {0xef1228, 0xc084a3e450}, 0x10ea2, 0xc084a3e5d0, 0xc08207e000, 0xc043ef2908)
	github.com/microsoft/typescript-go/internal/ls/documenthighlights.go:55 +0x105
github.com/microsoft/typescript-go/internal/ls.(*LanguageService).ProvideDocumentHighlights(0xc084a3e4b0, {0xef1228, 0xc084a3e450}, {0xc068c24070?, 0x30?}, {0x1bc008?, 0xc0?})
	github.com/microsoft/typescript-go/internal/ls/documenthighlights.go:45 +0x3be
github.com/microsoft/typescript-go/internal/lsp.(*Server).handleDocumentHighlight(0xc00027cb40?, {0xef1228?, 0xc084a3e450?}, 0xc068c24070?, 0x69?)
	github.com/microsoft/typescript-go/internal/lsp/server.go:947 +0x35
github.com/microsoft/typescript-go/internal/lsp.init.func1.registerLanguageServiceDocumentRequestHandler[...].25({0xef1228, 0xc084a3e450}, 0xc084d0c060)
	github.com/microsoft/typescript-go/internal/lsp/server.go:558 +0x11a
github.com/microsoft/typescript-go/internal/lsp.(*Server).handleRequestOrNotification(0xc000238008, {0xef1260?, 0xc0848d8d70?}, 0xc084d0c060)
	github.com/microsoft/typescript-go/internal/lsp/server.go:451 +0x153
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 34
	github.com/microsoft/typescript-go/internal/lsp/server.go:374 +0x9ad

https://github.com/microsoft/typescript-go/issues/2127#issuecomment-3558171176 has similar crashes

panic handling request textDocument/documentHighlight interface conversion: ast.nodeData is *ast.Token, not *ast.Identifier goroutine 360382 [running]:
runtime/debug.Stack()
	runtime/debug/stack.go:26 +0x5e
github.com/microsoft/typescript-go/internal/lsp.(*Server).recover(0xc000138608, 0xc04efb0990)
	github.com/microsoft/typescript-go/internal/lsp/server.go:572 +0x58
panic({0xb82b40?, 0xc04ea389c0?})
	runtime/panic.go:783 +0x132
github.com/microsoft/typescript-go/internal/ast.(*Node).AsIdentifier(...)
	github.com/microsoft/typescript-go/internal/ast/ast.go:1203
github.com/microsoft/typescript-go/internal/ast.(*Node).Text(0xb96bc0?)
	github.com/microsoft/typescript-go/internal/ast/ast.go:306 +0x4df
github.com/microsoft/typescript-go/internal/ls.isThis(...)
	github.com/microsoft/typescript-go/internal/ls/utilities.go:371
github.com/microsoft/typescript-go/internal/ls.getReferencedSymbolsSpecial(0xc04ea38930, {0xc04555fa70, 0x1, 0x1})
	github.com/microsoft/typescript-go/internal/ls/findallreferences.go:808 +0x2a8
github.com/microsoft/typescript-go/internal/ls.(*LanguageService).getReferencedSymbolsForNode(0xc04ea38840, {0xef1228, 0xc04ea387e0}, 0x1bd0, 0xc04ea38930, 0xc031255500, {0xc04555fa70, 0x1, 0x1}, {0x0, ...}, ...)
	github.com/microsoft/typescript-go/internal/ls/findallreferences.go:696 +0x571
github.com/microsoft/typescript-go/internal/ls.(*LanguageService).getSemanticDocumentHighlights(0xc04ea38840, {0xef1228, 0xc04ea387e0}, 0x1bd0, 0xc04ea38930, 0xc031255500, 0xc02b056908)
	github.com/microsoft/typescript-go/internal/ls/documenthighlights.go:55 +0x105
github.com/microsoft/typescript-go/internal/ls.(*LanguageService).ProvideDocumentHighlights(0xc04ea38840, {0xef1228, 0xc04ea387e0}, {0xc05cc40300?, 0x30?}, {0x7e808?, 0xc0?})
	github.com/microsoft/typescript-go/internal/ls/documenthighlights.go:45 +0x3be
github.com/microsoft/typescript-go/internal/lsp.(*Server).handleDocumentHighlight(0xc0002bcb40?, {0xef1228?, 0xc04ea387e0?}, 0xc05cc40300?, 0x60?)
	github.com/microsoft/typescript-go/internal/lsp/server.go:947 +0x35
github.com/microsoft/typescript-go/internal/lsp.init.func1.registerLanguageServiceDocumentRequestHandler[...].25({0xef1228, 0xc04ea387e0}, 0xc04efb0990)
	github.com/microsoft/typescript-go/internal/lsp/server.go:558 +0x11a
github.com/microsoft/typescript-go/internal/lsp.(*Server).handleRequestOrNotification(0xc000138608, {0xef1260?, 0xc042ba9270?}, 0xc04efb0990)
	github.com/microsoft/typescript-go/internal/lsp/server.go:451 +0x153
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 35
	github.com/microsoft/typescript-go/internal/lsp/server.go:374 +0x9ad

But then also:

panic handling request textDocument/documentHighlight did not expect KindJsxElement to have KindIdentifier in its trivia goroutine 359917 [running]:
runtime/debug.Stack()
	runtime/debug/stack.go:26 +0x5e
github.com/microsoft/typescript-go/internal/lsp.(*Server).recover(0xc000138608, 0xc04efb09f0)
	github.com/microsoft/typescript-go/internal/lsp/server.go:572 +0x58
panic({0xb46f40?, 0xc045d366e0?})
	runtime/panic.go:783 +0x132
github.com/microsoft/typescript-go/internal/astnav.getTokenAtPosition(0xc02b056908, 0x1bcf, 0x0, 0xdc9318)
	github.com/microsoft/typescript-go/internal/astnav/tokens.go:195 +0x5f9
github.com/microsoft/typescript-go/internal/astnav.GetTouchingPropertyName(0xc03f85c828?, 0xeeec70?)
	github.com/microsoft/typescript-go/internal/astnav/tokens.go:12 +0x1c
github.com/microsoft/typescript-go/internal/ls.(*LanguageService).ProvideDocumentHighlights(0xc04efb0b70, {0xef1228, 0xc04efb0b10}, {0xc03e6387e0?, 0x30?}, {0x601808?, 0xc0?})
	github.com/microsoft/typescript-go/internal/ls/documenthighlights.go:20 +0x8e
github.com/microsoft/typescript-go/internal/lsp.(*Server).handleDocumentHighlight(0xc0002bcb40?, {0xef1228?, 0xc04efb0b10?}, 0xc03e6387e0?, 0x60?)
	github.com/microsoft/typescript-go/internal/lsp/server.go:947 +0x35
github.com/microsoft/typescript-go/internal/lsp.init.func1.registerLanguageServiceDocumentRequestHandler[...].25({0xef1228, 0xc04efb0b10}, 0xc04efb09f0)
	github.com/microsoft/typescript-go/internal/lsp/server.go:558 +0x11a
github.com/microsoft/typescript-go/internal/lsp.(*Server).handleRequestOrNotification(0xc000138608, {0xef1260?, 0xc041a64320?}, 0xc04efb09f0)
	github.com/microsoft/typescript-go/internal/lsp/server.go:451 +0x153
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 35
	github.com/microsoft/typescript-go/internal/lsp/server.go:374 +0x9ad

And https://github.com/microsoft/typescript-go/issues/2127#issuecomment-3558264451 has the same crash:

panic handling request textDocument/documentHighlight did not expect KindJsxElement to have KindIdentifier in its trivia goroutine 426595 [running]:
runtime/debug.Stack()
	runtime/debug/stack.go:26 +0x5e
github.com/microsoft/typescript-go/internal/lsp.(*Server).recover(0xc000138608, 0xc066b773e0)
	github.com/microsoft/typescript-go/internal/lsp/server.go:572 +0x58
panic({0xb46f40?, 0xc06c845040?})
	runtime/panic.go:783 +0x132
github.com/microsoft/typescript-go/internal/astnav.getTokenAtPosition(0xc056148c08, 0x1bf5, 0x0, 0xdc9318)
	github.com/microsoft/typescript-go/internal/astnav/tokens.go:195 +0x5f9
github.com/microsoft/typescript-go/internal/astnav.GetTouchingPropertyName(0xc014c900d8?, 0xeeec70?)
	github.com/microsoft/typescript-go/internal/astnav/tokens.go:12 +0x1c
github.com/microsoft/typescript-go/internal/ls.(*LanguageService).ProvideDocumentHighlights(0xc057245350, {0xef1228, 0xc0572452f0}, {0xc00c35cde0?, 0x30?}, {0x600008?, 0xc0?})
	github.com/microsoft/typescript-go/internal/ls/documenthighlights.go:20 +0x8e
github.com/microsoft/typescript-go/internal/lsp.(*Server).handleDocumentHighlight(0xc0002bcb40?, {0xef1228?, 0xc0572452f0?}, 0xc00c35cde0?, 0x60?)
	github.com/microsoft/typescript-go/internal/lsp/server.go:947 +0x35
github.com/microsoft/typescript-go/internal/lsp.init.func1.registerLanguageServiceDocumentRequestHandler[...].25({0xef1228, 0xc0572452f0}, 0xc066b773e0)
	github.com/microsoft/typescript-go/internal/lsp/server.go:558 +0x11a
github.com/microsoft/typescript-go/internal/lsp.(*Server).handleRequestOrNotification(0xc000138608, {0xef1260?, 0xc03fed84b0?}, 0xc066b773e0)
	github.com/microsoft/typescript-go/internal/lsp/server.go:451 +0x153
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 35
	github.com/microsoft/typescript-go/internal/lsp/server.go:374 +0x9ad

jakebailey avatar Nov 20 '25 15:11 jakebailey

This one is quite literally impossible:

interface conversion: ast.nodeData is *ast.Token, not *ast.Identifier goroutine 360382 [running]:
runtime/debug.Stack()
	runtime/debug/stack.go:26 +0x5e
github.com/microsoft/typescript-go/internal/lsp.(*Server).recover(0xc000138608, 0xc04efb0990)
	github.com/microsoft/typescript-go/internal/lsp/server.go:572 +0x58
panic({0xb82b40?, 0xc04ea389c0?})
	runtime/panic.go:783 +0x132
github.com/microsoft/typescript-go/internal/ast.(*Node).AsIdentifier(...)
	github.com/microsoft/typescript-go/internal/ast/ast.go:1203
github.com/microsoft/typescript-go/internal/ast.(*Node).Text(0xb96bc0?)
	github.com/microsoft/typescript-go/internal/ast/ast.go:306 +0x4df
github.com/microsoft/typescript-go/internal/ls.isThis(...)
	github.com/microsoft/typescript-go/internal/ls/utilities.go:371

Because the code says:

func isThis(node *ast.Node) bool {
	switch node.Kind {
	case ast.KindThisKeyword:
		// case ast.KindThisType: TODO: GH#9267
		return true
	case ast.KindIdentifier:
		// 'this' as a parameter
		return node.Text() == "this" && node.Parent.Kind == ast.KindParameter
	default:
		return false
	}
}

And line 371 is the Text call, which is gated by KindIdentifier...

jakebailey avatar Nov 20 '25 16:11 jakebailey

Sounds like some code somewhere is calling factory.NewToken(ast.Identifier)!

ahejlsberg avatar Nov 23 '25 22:11 ahejlsberg