Panic Handling textDocument/onTypeFormatting
Closed this issue · 7 comments
jterk-lattice commented
Stack trace
panic handling request textDocument/onTypeFormatting runtime error: invalid memory address or nil pointer dereference goroutine 1314 [running]:
runtime/debug.Stack()
runtime/debug/stack.go:26 +0x64
github.com/microsoft/typescript-go/internal/lsp.(*Server).recover(0x1400010adc0, 0x1400ae41d40)
github.com/microsoft/typescript-go/internal/lsp/server.go:532 +0x44
panic({0x1011dd960?, 0x101aa2250?})
runtime/panic.go:783 +0x120
github.com/microsoft/typescript-go/internal/ast.(*Node).Pos(...)
github.com/microsoft/typescript-go/internal/ast/ast.go:240
github.com/microsoft/typescript-go/internal/scanner.GetTokenPosOfNode(0xa?, 0x140032e92a8?, 0x0?)
github.com/microsoft/typescript-go/internal/scanner/scanner.go:2318 +0xa8
github.com/microsoft/typescript-go/internal/astnav.GetStartOfNode(...)
github.com/microsoft/typescript-go/internal/astnav/tokens.go:380
github.com/microsoft/typescript-go/internal/ls.getRangeOfEnclosingComment(0x140031b4588, 0x1, 0x0, 0x0)
github.com/microsoft/typescript-go/internal/ls/format.go:147 +0x90
github.com/microsoft/typescript-go/internal/ls.isInComment(0x140031b4588, 0x1, 0x0)
github.com/microsoft/typescript-go/internal/ls/utilities.go:185 +0x44
github.com/microsoft/typescript-go/internal/ls.(*LanguageService).getFormattingEditsAfterKeystroke(0x14007775c38?, {0x1013bc710?, 0x1400669f220?}, 0x140031b4588, 0x14009dde480?, 0x1, {0x1011257b0, 0x1})
github.com/microsoft/typescript-go/internal/ls/format.go:116 +0x60
github.com/microsoft/typescript-go/internal/ls.(*LanguageService).ProvideFormatDocumentOnType(0x14007775c68, {0x1013bc710, 0x1400669f220}, {0x1400ae7a1c0?, 0x1?}, 0x1400ae549c0, {0x2580000?, 0x140?}, {0x1011257b0, 0x1})
github.com/microsoft/typescript-go/internal/ls/format.go:78 +0xfc
github.com/microsoft/typescript-go/internal/lsp.(*Server).handleDocumentOnTypeFormat(0x140003521c0?, {0x1013bc710?, 0x1400669f220?}, 0x1400ae7a1c0?, 0x34?)
github.com/microsoft/typescript-go/internal/lsp/server.go:806 +0x40
github.com/microsoft/typescript-go/internal/lsp.init.func1.registerLanguageServiceDocumentRequestHandler[...].21({0x1013bc710, 0x1400669f220}, 0x1400ae41d40)
github.com/microsoft/typescript-go/internal/lsp/server.go:518 +0xe0
github.com/microsoft/typescript-go/internal/lsp.(*Server).handleRequestOrNotification(0x1400010adc0, {0x1013bc710, 0x1400669f220}, 0x1400ae41d40)
github.com/microsoft/typescript-go/internal/lsp/server.go:424 +0xf4
github.com/microsoft/typescript-go/internal/lsp.(*Server).dispatchLoop.func1()
github.com/microsoft/typescript-go/internal/lsp/server.go:329 +0x34
created by github.com/microsoft/typescript-go/internal/lsp.(*Server).dispatchLoop in goroutine 34
github.com/microsoft/typescript-go/internal/lsp/server.go:349 +0x6f8
Steps to reproduce
- Create an empty directory
npm init -ynpm install --save @typescript/native-preview- Open an empty
index.tsfile - Press
<enter>to insert a newline
jterk-lattice commented
7.0.0-dev.20250716.1 appears to be the first version that exhibits this problem.
Record of my testing:
7.0.0-dev.20250801.1reproduces7.0.0-dev.20250701.1does not7.0.0-dev.20250715.1does not7.0.0-dev.20250723.1does7.0.0-dev.20250719.1does7.0.0-dev.20250716.1does
jterk-lattice commented
So likely e62a044 ?
jterk-lattice commented
@DanielRosenwasser FYI performed the binary search you asked for on #1719
jterk-lattice commented
Verified that I can no longer reproduce with v7.0.0-dev.20251021.1. Thanks!
Girbi commented
I still get this panic error
RyanCavanaugh commented
@Girbi can you log a new issue with repro steps? Thanks!