Skip to content

LSP: Autoimports panic on text completion (just typing) #1661

@lukpsaxo

Description

@lukpsaxo

Stack trace

panic handling request textDocument/completion runtime error: invalid memory address or nil pointer dereference goroutine 369150 [running]:
runtime/debug.Stack()
	runtime/debug/stack.go:26 +0x5e
github.com/microsoft/typescript-go/internal/lsp.(*Server).recover(0xc00016cdc0, 0xc105d34c60)
	github.com/microsoft/typescript-go/internal/lsp/server.go:532 +0x58
panic({0x7ff7e254db60?, 0x7ff7e2fc9ad0?})
	runtime/panic.go:783 +0x132
github.com/microsoft/typescript-go/internal/ls.tryUseExistingNamespaceImport({0xc01ef7f5f0, 0x1, 0xc040846008?}, {0xf1ae6000?, 0xc1?})
	github.com/microsoft/typescript-go/internal/ls/autoimports.go:868 +0x1b5
github.com/microsoft/typescript-go/internal/ls.(*LanguageService).getImportFixes(0xc07b392a08, 0xc040846008, {0xc1c8d689e0, 0x2, 0x2}, 0xc0b593b4a0, 0xc0272bc957, 0xc0272bc956, 0xc23c37eb08, {0xc01be62c40, ...}, ...)
	github.com/microsoft/typescript-go/internal/ls/autoimports.go:628 +0xfe
github.com/microsoft/typescript-go/internal/ls.(*importSpecifierResolverForCompletions).getModuleSpecifierForBestExportInfo(0xc0272bdc30, 0xc040846008, {0xc1c8d689e0, 0x2?, 0xc0272bcb78?}, 0x836, 0x0)
	github.com/microsoft/typescript-go/internal/ls/autoimports.go:552 +0x270
github.com/microsoft/typescript-go/internal/ls.(*LanguageService).getCompletionData.func9.1({0xc1c8d689e0?, 0x43?, 0xc1e20ad8c8?}, {0xc1d666a470, 0x11}, 0x78?, {{0xc1d666a470, 0x11}, 0x136e, {0x0, ...}, ...})
	github.com/microsoft/typescript-go/internal/ls/completions.go:1220 +0x11f
github.com/microsoft/typescript-go/internal/ls.(*exportInfoMap).search(0xc0272bd090, 0xc040846008, {0xc1fa1b0540?, 0x7ff7e1e8637f?}, 0x0, 0xc0272bd1f8, 0xc0272bd338)
	github.com/microsoft/typescript-go/internal/ls/autoimports.go:237 +0x30e
github.com/microsoft/typescript-go/internal/ls.(*LanguageService).searchExportInfosForCompletions(0xc07b392a08, {0x7ff7e28a59d0, 0xc007ae3630}, 0xc040846008, 0xc23c37eb08, 0xc0e19eacf0, 0x0, 0x0, 0x0, {0xc218079835, ...}, ...)
	github.com/microsoft/typescript-go/internal/ls/autoimportsexportinfo.go:172 +0x3da
github.com/microsoft/typescript-go/internal/ls.(*LanguageService).getCompletionData.func9()
	github.com/microsoft/typescript-go/internal/ls/completions.go:1271 +0x26c
github.com/microsoft/typescript-go/internal/ls.(*LanguageService).getCompletionData.func17()
	github.com/microsoft/typescript-go/internal/ls/completions.go:1686 +0x5f6
github.com/microsoft/typescript-go/internal/ls.(*LanguageService).getCompletionData.func18(...)
	github.com/microsoft/typescript-go/internal/ls/completions.go:1713
github.com/microsoft/typescript-go/internal/ls.(*LanguageService).getCompletionData(0xc07b392a08, {0x7ff7e28a59d0, 0xc007ae3630}, 0xc040846008, 0xc23c37eb08, 0x836, 0xc0e19eacf0)
	github.com/microsoft/typescript-go/internal/ls/completions.go:1741 +0x1ee2
github.com/microsoft/typescript-go/internal/ls.(*LanguageService).getCompletionsAtPosition(0xc07b392a08, {0x7ff7e28a59d0, 0xc007ae3630}, 0xc23c37eb08, 0x836, 0x0, 0xc0e19eacf0, 0xc0001fef60)
	github.com/microsoft/typescript-go/internal/ls/completions.go:399 +0x2dd
github.com/microsoft/typescript-go/internal/ls.(*LanguageService).ProvideCompletion(0xc07b392a08, {0x7ff7e28a59d0, 0xc007ae3630}, {0xc020f4df10?, 0xc1da07fe70?}, {0xe244bd8b?, 0x7ff7?}, 0xc0ba1af980, 0xc0001fef60, 0xc0e19eacf0)
	github.com/microsoft/typescript-go/internal/ls/completions.go:50 +0xe7
github.com/microsoft/typescript-go/internal/lsp.(*Server).handleCompletion(0xc0003501c0?, {0x7ff7e28a59d0, 0xc007ae3630}, 0xc07b392a08, 0xc105d34a50)
	github.com/microsoft/typescript-go/internal/lsp/server.go:754 +0xff
github.com/microsoft/typescript-go/internal/lsp.init.func1.registerLanguageServiceDocumentRequestHandler[...].15({0x7ff7e28a59d0, 0xc007ae3630}, 0xc105d34c60)
	github.com/microsoft/typescript-go/internal/lsp/server.go:518 +0x130
github.com/microsoft/typescript-go/internal/lsp.(*Server).handleRequestOrNotification(0xc00016cdc0, {0x7ff7e28a59d0, 0xc007ae3630}, 0xc105d34c60)
	github.com/microsoft/typescript-go/internal/lsp/server.go:424 +0x10d
github.com/microsoft/typescript-go/internal/lsp.(*Server).dispatchLoop.func1()
	github.com/microsoft/typescript-go/internal/lsp/server.go:329 +0x3a
created by github.com/microsoft/typescript-go/internal/lsp.(*Server).dispatchLoop in goroutine 23
	github.com/microsoft/typescript-go/internal/lsp/server.go:349 +0x8aa

[Error - 11:21:54 AM] Request textDocument/completion failed.
  Message: InternalError: panic handling request textDocument/completion: runtime error: invalid memory address or nil pointer dereference
  Code: -32603 

Steps to reproduce

Sorry, will keep an eye out but it seems to happen regularly just editing files.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions