Skip to content

Panic on textDocument/definition #1673

@lukpsaxo

Description

@lukpsaxo

Stack trace

panic handling request textDocument/definition bad line number. Line: 65, lineMap length: 33 goroutine 74379 [running]:
runtime/debug.Stack()
	runtime/debug/stack.go:26 +0x5e
github.com/microsoft/typescript-go/internal/lsp.(*Server).recover(0xc0000f4dc0, 0xc05d9571d0)
	github.com/microsoft/typescript-go/internal/lsp/server.go:532 +0x58
panic({0x7ff76dc5a4c0?, 0xc02a3d9970?})
	runtime/panic.go:783 +0x132
github.com/microsoft/typescript-go/internal/ls.(*Converters).LineAndCharacterToPosition(0xc025592360, {0x7ff76dfe4430, 0xc03fbe7608}, {0x0?, 0x0?})
	github.com/microsoft/typescript-go/internal/ls/converters.go:143 +0x2d9
github.com/microsoft/typescript-go/internal/ls.(*LanguageService).ProvideDefinition(0xc010739488, {0x7ff76dfe59d0, 0xc05eecf360}, {0xc02e3db420?, 0x7ff76d5a94f0?}, {0x0?, 0x0?})
	github.com/microsoft/typescript-go/internal/ls/definition.go:17 +0xac
github.com/microsoft/typescript-go/internal/lsp.(*Server).handleDefinition(0xc0003501c0?, {0x7ff76dfe59d0?, 0xc05eecf360?}, 0xc02e3db420?, 0x65?)
	github.com/microsoft/typescript-go/internal/lsp/server.go:735 +0x35
github.com/microsoft/typescript-go/internal/lsp.init.func1.registerLanguageServiceDocumentRequestHandler[...].13({0x7ff76dfe59d0, 0xc05eecf360}, 0xc05d9571d0)
	github.com/microsoft/typescript-go/internal/lsp/server.go:518 +0x13f
github.com/microsoft/typescript-go/internal/lsp.(*Server).handleRequestOrNotification(0xc0000f4dc0, {0x7ff76dfe59d0, 0xc05eecf360}, 0xc05d9571d0)
	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 10
	github.com/microsoft/typescript-go/internal/lsp/server.go:349 +0x8aa

[Error - 9:42:06 AM] Request textDocument/definition failed.
  Message: InternalError: panic handling request textDocument/definition: bad line number. Line: 65, lineMap length: 33
  Code: -32603 

Steps to reproduce

I couldn't easily reproduce again. I was commenting out some code and then it appeared to error when the editor lost focus. I tried re-doing edits and it didn't occur.

The file I am in has 44 lines so not sure where bad line number 65 or line map length 33 came from.

Checking the LSP logs:

[Trace - 9:42:06 AM] Sending request 'textDocument/definition - (54)'.
Params: {
    "textDocument": {
        "uri": "file:///c%3A/Projects/a/b/c.play.ts"
    },
    "position": {
        "line": 65,
        "character": 24
    }
}


[Trace - 9:42:06 AM] Received response 'textDocument/definition - (54)' in 1ms. Request failed: InternalError: panic handling request textDocument/definition: bad line number. Line: 65, lineMap length: 33 (-32603).

so It seems it is a vscode issue - asking for a wrong line number?!

Feel free to close - I guess when this is production it will ignore errors like this instead of popping up.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions