a-h / templ

A language for writing HTML user interfaces in Go.
https://templ.guide/
MIT License
7.14k stars 236 forks source link

Vscode plugin crash #820

Closed stekyne closed 4 days ago

stekyne commented 6 days ago
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x10 pc=0xa89f80]

goroutine 25 [running]:
github.com/a-h/templ/cmd/templ/lspcmd/proxy.(*Server).CodeAction(0xc0001e6050, {0xc75440, 0xc0001e62d0}, 0xc000035920)
    C:/Users/steve/go/pkg/mod/github.com/a-h/templ@v0.2.513/cmd/templ/lspcmd/proxy/server.go:284 +0x480
github.com/a-h/protocol.serverDispatch({0xc75440, 0xc0001e62d0}, {0xc79d10, 0xc0001e6050}, 0xc00049a300, {0xc75600, 0xc0001b6780})
    C:/Users/steve/go/pkg/mod/github.com/a-h/protocol@v0.0.0-20230224160810-b4eec67c1c22/server.go:158 +0x4013
github.com/a-h/protocol.NewServer.ServerHandler.func1({0xc75440, 0xc0001e62d0}, 0xc00049a300, {0xc75600, 0xc0001b6780})
    C:/Users/steve/go/pkg/mod/github.com/a-h/protocol@v0.0.0-20230224160810-b4eec67c1c22/server.go:36 +0x7e
github.com/a-h/protocol.Handlers.ReplyHandler.func1({0xc75440, 0xc0001e62d0}, 0xc0001d6870, {0xc75600?, 0xc0001b6780?})
    C:/Users/steve/go/pkg/mod/go.lsp.dev/jsonrpc2@v0.10.0/handler.go:35 +0xe5
github.com/a-h/protocol.Handlers.AsyncHandler.func2.2()
    C:/Users/steve/go/pkg/mod/go.lsp.dev/jsonrpc2@v0.10.0/handler.go:114 +0x76
created by github.com/a-h/protocol.Handlers.AsyncHandler.func2 in goroutine 20
    C:/Users/steve/go/pkg/mod/go.lsp.dev/jsonrpc2@v0.10.0/handler.go:112 +0x18f
[Error - 11:57:21 AM] Connection to server got closed. Server will not be restarted.
[Error - 11:57:21 AM] Server process exited with code 2.

I've been getting this error when trying to load the VScode plugin lately. It's not really useable at the moment but it was working until recently. Maybe the plugin update in the last few days that caused this?

a-h commented 5 days ago

Hi, there seems to have been a change in gopls which surfaced a lack of nil check that had been in the templ LSP for a long time. That issue was fixed in the latest release.

From the logs you provided, it looks like you're using a version of the templ CLI that's around 10 versions behind the current release, so it's worth you upgrading your CLI version to see if that solves the issue. There have been a lot of improvements and minor bug fixes since January.

stekyne commented 5 days ago

Edit: Ok great that helped thank you. I misread what you said at first. Upgrading the gotools and templ has resolved the issue.

a-h commented 4 days ago

Hey, just to follow up on this one, it turns out that my first attempt at a fix didn't quite do the job. I worked out how to reproduce the issue, and believe it's now fixed in main. As soon as I get confirmation from others that it's sorted, I'll push a new version out.

Sorry for the inconvenience.

axzilla commented 4 days ago

Hey, just to follow up on this one, it turns out that my first attempt at a fix didn't quite do the job. I worked out how to reproduce the issue, and believe it's now fixed in main. As soon as I get confirmation from others that it's sorted, I'll push a new version out.

Sorry for the inconvenience.

Is this related to LSP or VSCode? I'm asking because LSP (autocomplete/imports) hasn't been working for me in NeoVim with the latest versions either.