a-h / templ

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

Server initialization failed. #813

Closed MukundSinghRajput closed 3 months ago

MukundSinghRajput commented 3 months ago

[Error - 7:50:12 PM] Server process exited with code 1. [Error - 7:50:12 PM] Server initialization failed. Message: Pending response rejected since connection got disposed Code: -32097 [Error - 7:50:12 PM] Connection to server got closed. Server will not be restarted. [Error - 7:50:12 PM] templ client: couldn't create connection to server. Message: Pending response rejected since connection got disposed Code: -32097

heitorfreitasferreira commented 3 months ago

I'm having the same trouble, here is the output of the error in my machine (using wsl2/arch, don't know if the info in relevant)

[Info  - 2:08:05 PM] 2024/06/26 14:08:05 Created View (#1)
    directory=/home/heitor/repos/go-library-manager
    view_type="GoMod"
    root_dir="file:///home/heitor/repos/go-library-manager"
    go_version="go version go1.22.4 linux/amd64"
    build_flags=[]
    env={GOOS:linux GOARCH:amd64 GOCACHE:/home/heitor/.cache/go-build GOMODCACHE:/home/heitor/go/pkg/mod GOPATH:/home/heitor/go GOPRIVATE: GOFLAGS: GO111MODULE: GoVersion:22 GoVersionOutput:go version go1.22.4 linux/amd64
 ExplicitGOWORK: EffectiveGOPACKAGESDRIVER:}
    env_overlay=[]

[Info  - 2:08:06 PM] 2024/06/26 14:08:06 go/packages.Load #1
    view_id="1"
    snapshot=0
    directory=/home/heitor/repos/go-library-manager
    query=[/home/heitor/repos/go-library-manager/... builtin]
    packages=11
    duration=1.096788128s

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

goroutine 23 [running]:
github.com/a-h/templ/cmd/templ/lspcmd/proxy.(*Server).CodeAction(0xc00008a4b0, {0xa55290, 0xc0002c43c0}, 0xc00012f4a0)
    /home/heitor/go/pkg/mod/github.com/a-h/templ@v0.2.707/cmd/templ/lspcmd/proxy/server.go:294 +0x480
github.com/a-h/protocol.serverDispatch({0xa55290, 0xc0002c43c0}, {0xa5b340, 0xc00008a4b0}, 0xc000119800, {0xa55568, 0xc000288d00})
    /home/heitor/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({0xa55290, 0xc0002c43c0}, 0xc000119800, {0xa55568, 0xc000288d00})
    /home/heitor/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({0xa55290, 0xc0002c43c0}, 0xc000280e58, {0xa55568, 0xc000288d00})
    /home/heitor/go/pkg/mod/go.lsp.dev/jsonrpc2@v0.10.0/handler.go:35 +0xc6
github.com/a-h/protocol.Handlers.AsyncHandler.func2.2()
    /home/heitor/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 11
    /home/heitor/go/pkg/mod/go.lsp.dev/jsonrpc2@v0.10.0/handler.go:112 +0x165
[Error - 2:08:34 PM] Connection to server got closed. Server will not be restarted.
[Error - 2:08:34 PM] Server process exited with code 2.

image

And the coloring work in some files but not others?

emarifer commented 3 months ago

I have also received that message and, although I don't know if the problem may be related, I fixed it (in vscode) by downgrading the version from gopls@v0.16.0 to gopls@v0.14.0.

heitorfreitasferreira commented 3 months ago

I have also received that message and, although I don't know if the problem may be related, I fixed it (in vscode) by downgrading the version from gopls@v0.16.0 to gopls@v0.14.0.

Tanks bro, that helped for now!

joerdav commented 3 months ago

The next version of templ will solve this issue, so going to close this for now, thanks for raising.

a-h commented 3 months ago

Fixed in https://github.com/a-h/templ/releases/tag/v0.2.731