Inlayhint panic
Stack trace
panic handling request textDocument/inlayHint bad line number. Line: 109, lineMap length: 109 goroutine 2804779 [running]:
runtime/debug.Stack()
runtime/debug/stack.go:26 +0x5e
github.com/microsoft/typescript-go/internal/lsp.(*Server).recover(0xc0000ecdc0, 0xc1512c22d0)
github.com/microsoft/typescript-go/internal/lsp/server.go:572 +0x58
panic({0x7ff658b6dae0?, 0xc0050479c0?})
runtime/panic.go:783 +0x132
github.com/microsoft/typescript-go/internal/ls/lsconv.(*Converters).LineAndCharacterToPosition(0xc1798b0000, {0x7ff658f0be70, 0xc025c31b08}, {0x58a40240?, 0x7ff6?})
github.com/microsoft/typescript-go/internal/ls/lsconv/converters.go:143 +0x2d9
github.com/microsoft/typescript-go/internal/ls/lsconv.(*Converters).FromLSPRange(0xc1798b0000, {0x7ff658f0be70, 0xc025c31b08}, {{0x25c31b08?, 0xc0?}, {0x0?, 0x0?}})
github.com/microsoft/typescript-go/internal/ls/lsconv/converters.go:43 +0x4c
github.com/microsoft/typescript-go/internal/ls.(*LanguageService).ProvideInlayHint(0xc181be80c0, {0x7ff658f0d860, 0xc11a99e050}, 0xc1512c22a0)
github.com/microsoft/typescript-go/internal/ls/inlay_hints.go:38 +0x165
github.com/microsoft/typescript-go/internal/lsp.(*Server).handleInlayHint(0xc000322b40?, {0x7ff658f0d860?, 0xc11a99e050?}, 0xc05ff13b60?, 0x60?)
github.com/microsoft/typescript-go/internal/lsp/server.go:998 +0x25
github.com/microsoft/typescript-go/internal/lsp.init.func1.registerLanguageServiceDocumentRequestHandler[...].27({0x7ff658f0d860, 0xc11a99e050}, 0xc1512c22d0)
github.com/microsoft/typescript-go/internal/lsp/server.go:558 +0x11a
github.com/microsoft/typescript-go/internal/lsp.(*Server).handleRequestOrNotification(0xc0000ecdc0, {0x7ff658f0d860, 0xc11a99e050}, 0xc1512c22d0)
github.com/microsoft/typescript-go/internal/lsp/server.go:451 +0x10d
github.com/microsoft/typescript-go/internal/lsp.(*Server).dispatchLoop.func1()
github.com/microsoft/typescript-go/internal/lsp/server.go:356 +0x3a
created by github.com/microsoft/typescript-go/internal/lsp.(*Server).dispatchLoop in goroutine 10
github.com/microsoft/typescript-go/internal/lsp/server.go:376 +0x9ad
[Error - 2:08:44 PM] Request textDocument/inlayHint failed.
Message: InternalError: panic handling request textDocument/inlayHint: bad line number. Line: 109, lineMap length: 109
Steps to reproduce
Sorry not sure - feel free to close if its not useful.
I am also seeing this sometimes without a panic in the logs. E.g. I see this:
I open the logs and see nothing - some time stamps are messed up and no logs for the time it happens
[14:45:37.400] ATA:: #12 with cwd: C:/Users/lukp/AppData/Local/Microsoft/TypeScript/7.0 arguments: [@types/picomatch@latest]
[14:46:47.909] ATA:: Output is:
[14:46:47.909] TI:: npm install #12 completed
[14:46:47.909] ATA:: install request failed, marking packages as missing to prevent repeated requests: [picomatch]
[14:46:48.024] ======== Triggering ATA for project c:/Projects/SaxoTrader/SaxoTrader/jsconfig.json ========
[14:45:37.317] ATA:: Typing names in 'c:/Projects/x/y/node_modules/readline/package.json' dependencies: [tap iconv-lite]
and then I open the lsp logs and I do see the issue
[Trace - 2:46:42 PM] Received response 'textDocument/inlayHint - (10791)' in 85ms. Request failed: InternalError: panic handling request textDocument/inlayHint: bad line number. Line: 143, lineMap length: 142 (-32603).
I'm not sure if thats a logging issue or I shouldn't always expect a panic when I get a dialog?
One way to figure out the "cause" is to delete more and more of the file that triggers the panic until you're left with a minimal set of declarations and statements.
Actually, this is just something weird about the request as a whole exceeding the line count we have.
Most of the errors are during branch change or rename or editing and I see a new error every 20 minutes so it would take a very long time to work out the repro. I try and remember when i see an error and correlate it with what I do.
Is it possible that when a file update comes in, VS Code knows about it, but makes a request for the new contents before we're receiving any file updates? In other words:
- VS Code gets the file update
- The editor makes an
document/inlayHintsrequest using the new file bounds (for a file that may have grown in line length) - The editor then sends the update to us.
@mjbvz @andrewbranch @jakebailey
If so, that would be a major bug in VS Code or the LSP client library affecting practically any other request. The LS can't know about the first thing at all, only the request and the file update notification as they come over the pipe, of course.
It's suspicious that we don't see this sort of thing at all with say, tsserver.
The raw LSP logs would provide insight to that.
I get this reasonably often I think so let me know how I can provide more info. Im not sure how to get the raw lsp logs, I assume that is not just the lsp logs you get from the extension.
That is what me mean, the output window labeled LSP. Note that this contains loads of info including file contents.
Seems related to #1673.
======== Cache Statistics ========
[23:15:46.482] Open file count: 2
[23:15:46.482] Cached disk files: 8960
[23:15:46.482] Project count: 2
[23:15:46.482] Config count: 20
[23:15:46.482] Parse cache size: 7564
[23:15:46.482] Program count: 2
[23:15:46.482] Extended config cache size: 0
[23:15:46.482] Updated watches in 116.084µs
panic handling request textDocument/inlayHint bad line number. Line: 145, lineMap length: 145 goroutine 82087 [running]:
runtime/debug.Stack()
runtime/debug/stack.go:26 +0x64
github.com/microsoft/typescript-go/internal/lsp.(*Server).recover(0x140001ce008, 0x144f4300de0)
github.com/microsoft/typescript-go/internal/lsp/server.go:579 +0x44
panic({0x100ad5700?, 0x144fe063bb0?})
runtime/panic.go:783 +0x120
github.com/microsoft/typescript-go/internal/ls/lsconv.(*Converters).LineAndCharacterToPosition(0x144f4e855a8, {0x100d02610, 0x144f2ef8908}, {0x844790?, 0x1?})
github.com/microsoft/typescript-go/internal/ls/lsconv/converters.go:147 +0x29c
github.com/microsoft/typescript-go/internal/ls/lsconv.(*Converters).FromLSPRange(0x144f4e855a8, {0x100d02610, 0x144f2ef8908}, {{0xf2ef8908?, 0x144?}, {0x0?, 0x0?}})
github.com/microsoft/typescript-go/internal/ls/lsconv/converters.go:47 +0x4c
github.com/microsoft/typescript-go/internal/ls.(*LanguageService).ProvideInlayHint(0x144f7803260, {0x100d04b48, 0x144f4298690}, 0x144f4300db0)
github.com/microsoft/typescript-go/internal/ls/inlay_hints.go:38 +0x118
github.com/microsoft/typescript-go/internal/lsp.(*Server).handleInlayHint(0x1400022eb40?, {0x100d04b48?, 0x144f4298690?}, 0x14023f45050?, 0x84?)
github.com/microsoft/typescript-go/internal/lsp/server.go:973 +0x2c
github.com/microsoft/typescript-go/internal/lsp.init.func1.registerLanguageServiceDocumentRequestHandler[...].27({0x100d04b48, 0x144f4298690}, 0x144f4300de0)
github.com/microsoft/typescript-go/internal/lsp/server.go:565 +0xe0
github.com/microsoft/typescript-go/internal/lsp.(*Server).handleRequestOrNotification(0x140001ce008, {0x100d04b80?, 0x144f4003ae0?}, 0x144f4300de0)
github.com/microsoft/typescript-go/internal/lsp/server.go:458 +0x128
github.com/microsoft/typescript-go/internal/lsp.(*Server).dispatchLoop.func1()
github.com/microsoft/typescript-go/internal/lsp/server.go:361 +0x34
created by github.com/microsoft/typescript-go/internal/lsp.(*Server).dispatchLoop in goroutine 22
github.com/microsoft/typescript-go/internal/lsp/server.go:381 +0x7a0
[23:15:46.562] Processed 2 file changes in 9.456916ms
[Error - 11:15:46 PM] Request textDocument/inlayHint failed.
Message: InternalError: panic handling request textDocument/inlayHint: bad line number. Line: 145, lineMap length: 145
Code: -32603
Found the same panic crash. In the same file, I had this as well, so I don't know if it's entirely related:
Excessive stack depth comparing types 'Path<?, P>' and 'Path<?, P>'.ts(2321)
⌘+click to open in new tab
Excessive stack depth comparing types 'Path<O, ?>' and 'Path<O, ?>'.ts(2321)
⌘+click to open in new tab
Type instantiation is excessively deep and possibly infinite.ts(2589)
⌘+click to open in new tab
⚠ Error (TS2321) |
Excessive stack depth comparing types
and
⚠ Error (TS2321) |
Excessive stack depth comparing types
and
⚠ Error (TS2589)
|
Type instantiation is excessively deep and possibly infinite.
This is a 3rd panic related to inlay hint, different from the original and #2131
[09:20:47.629] Processed 2 file changes in 0s
panic handling request textDocument/inlayHint runtime error: invalid memory address or nil pointer dereference goroutine 404286 [running]:
runtime/debug.Stack()
runtime/debug/stack.go:26 +0x5e
github.com/microsoft/typescript-go/internal/lsp.(*Server).recover(0xc00014c008, 0xc097f751d0)
github.com/microsoft/typescript-go/internal/lsp/server.go:572 +0x58
panic({0x7ff68936f980?, 0x7ff689d0b7a0?})
runtime/panic.go:783 +0x132
github.com/microsoft/typescript-go/internal/ls.isAnyInlayHintEnabled(...)
github.com/microsoft/typescript-go/internal/ls/inlay_hints.go:900
github.com/microsoft/typescript-go/internal/ls.(*LanguageService).ProvideInlayHint(0xc2a7c7e360, {0x7ff6896e7f08, 0xc2a7c7e300}, 0xc097f751a0)
github.com/microsoft/typescript-go/internal/ls/inlay_hints.go:28 +0x65
github.com/microsoft/typescript-go/internal/lsp.(*Server).handleInlayHint(0xc00031eb40?, {0x7ff6896e7f08?, 0xc2a7c7e300?}, 0xc076650c00?, 0x77?)
github.com/microsoft/typescript-go/internal/lsp/server.go:963 +0x25
github.com/microsoft/typescript-go/internal/lsp.init.func1.registerLanguageServiceDocumentRequestHandler[...].27({0x7ff6896e7f08, 0xc2a7c7e300}, 0xc097f751d0)
github.com/microsoft/typescript-go/internal/lsp/server.go:558 +0x11a
github.com/microsoft/typescript-go/internal/lsp.(*Server).handleRequestOrNotification(0xc00014c008, {0x7ff6896e7f40?, 0xc19d29f8b0?}, 0xc097f751d0)
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 10
github.com/microsoft/typescript-go/internal/lsp/server.go:374 +0x9ad
lsp logs:
[Trace - 9:20:47 AM] Received response 'textDocument/inlayHint - (8)' in 8310ms. Request failed: InternalError: panic handling request textDocument/inlayHint: runtime error: invalid memory address or nil pointer dereference (-32603).
I've saved the lsp logs and server logs so I can extract bits or send the whole thing privately if you want.
Looking at what the lsp logs are I think it happened something like this:
- I was on a branch where a file was deleted and the deleted file was open
- I switched to a branch where the file was no longer deleted
- It requested inlay hint for the file that is now no longer deleted
- I closed the file int he editor
- now 8 seconds since inlay hints were requested for the file, it panics
The logs would be super helpful. You can send them to jabaile at microsoft.com.
I sent full logs+lsp for a panic on friday and then full logs+lsp for the line mismatch panic today. Subject line contains "Logs for tsgo issue 2077"