Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connection to server got closed. Server will not be restarted. (source: templ-vscode) #803

Closed
WilfredDube opened this issue Jun 23, 2024 · 4 comments

Comments

@WilfredDube
Copy link

Since yesterday my templ files can't be formatted by pressing: (Ctrl+Shift+I) in VS Code or VSCodium.

Screenshot from 2024-06-23 11-46-38

When the editors open the following error message pops up:

Screenshot from 2024-06-23 11-32-34

This is the output:

[Info  - 10:36:38 AM] 2024/06/23 10:36:38 Created View (#1)
	directory=/Projects/app
	view_type="GoMod"
	root_dir="file:///Projects/app"
	go_version="go version go1.22.2 linux/amd64"
	build_flags=[]
	env={GOOS:linux GOARCH:amd64 GOCACHE:/home/user/.cache/go-build GOMODCACHE:/home/user/go/pkg/mod GOPATH:/home/user/go GOPRIVATE: GOFLAGS: GO111MODULE: GoVersion:22 GoVersionOutput:go version go1.22.2 linux/amd64
 ExplicitGOWORK: EffectiveGOPACKAGESDRIVER:}
	env_overlay=[]

[Info  - 10:36:40 AM] 2024/06/23 10:36:40 go/packages.Load #1
	view_id="1"
	snapshot=0
	directory=/Projects/app
	query=[/Projects/app/... builtin]
	packages=16
	duration=1.986667775s

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x10 pc=0x87a600]

goroutine 56 [running]:
github.com/a-h/templ/cmd/templ/lspcmd/proxy.(*Server).CodeAction(0xc00008a4b0, {0xa55250, 0xc000250140}, 0xc000214ba0)
	/home/user/go/pkg/mod/github.com/a-h/[email protected]/cmd/templ/lspcmd/proxy/server.go:294 +0x480
github.com/a-h/protocol.serverDispatch({0xa55250, 0xc000250140}, {0xa5b300, 0xc00008a4b0}, 0xc0004529f0, {0xa55528, 0xc000216440})
	/home/user/go/pkg/mod/github.com/a-h/[email protected]/server.go:158 +0x4013
github.com/a-h/protocol.NewServer.ServerHandler.func1({0xa55250, 0xc000250140}, 0xc0004529f0, {0xa55528, 0xc000216440})
	/home/user/go/pkg/mod/github.com/a-h/[email protected]/server.go:36 +0x7e
github.com/a-h/protocol.Handlers.ReplyHandler.func1({0xa55250, 0xc000250140}, 0xc00020e0f0, {0xa55528, 0xc000216440})
	/home/user/go/pkg/mod/go.lsp.dev/[email protected]/handler.go:35 +0xc6
github.com/a-h/protocol.Handlers.AsyncHandler.func2.2()
	/home/user/go/pkg/mod/go.lsp.dev/[email protected]/handler.go:114 +0x76
created by github.com/a-h/protocol.Handlers.AsyncHandler.func2 in goroutine 11
	/home/user/go/pkg/mod/go.lsp.dev/[email protected]/handler.go:112 +0x165
[Error - 10:36:41 AM] Server process exited with code 2.
[Error - 10:36:41 AM] Connection to server got closed. Server will not be restarted.

I reinstalled the templ extension and added this in my settings.json but nothing works. It has been working well before and I can't trace back the steps that got me to this point.

{
    "editor.formatOnSave": true,
    "[templ]": {
        "editor.defaultFormatter": "a-h.templ"
    },
}

These are some of extension settings for templ. I'm not sure what I'm supposed to do here.
Screenshot from 2024-06-23 11-43-22

@prencher
Copy link

prencher commented Jun 24, 2024

Seeing the same on macOS with the latest VS Code (v1.90), Go extension (v0.41.4, gopls v0.16.0, go v1.22.3), and templ-vscode extension (v0.0.25, templ v0.2.707).

@rAlexander89
Copy link

same

@joerdav
Copy link
Collaborator

joerdav commented Jun 24, 2024

This has been fixed in mainline, it was a result of a change in gopls, so should be resolved in the next release. Alternatively you can install mainline now go install github.com/a-h/templ/cmd/templ@main.

@prencher
Copy link

Unfortunately changing to main now causes the issues outlined in #801.

For anybody else looking for a fix for this and running into issues after changing to main, follow along on that issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants