surrealdb / surrealdb.go

SurrealDB SDK for Golang
https://surrealdb.com
Apache License 2.0
232 stars 60 forks source link

Bug: Re-connection to the DB #110

Open iliesh opened 10 months ago

iliesh commented 10 months ago

Describe the bug

When the application is running, and the DB is restarted, then the application panic with the following stack:

panic: repeated read on failed websocket connection

goroutine 50 [running]:
github.com/gorilla/websocket.(*Conn).NextReader(0xc0000e0580)
        /home/admin/go/pkg/mod/github.com/gorilla/websocket@v1.5.0/conn.go:1030 +0x4f4
github.com/gorilla/websocket.(*Conn).ReadMessage(0x129dfa0?)
        /home/admin/go/pkg/mod/github.com/gorilla/websocket@v1.5.0/conn.go:1093 +0x2f
github.com/surrealdb/surrealdb.go/internal/websocket.(*WebSocket).read(0xc00039c080, {0xca5720, 0xc0003f4480})
        /home/admin/go/pkg/mod/github.com/surrealdb/surrealdb.go@v0.2.1/internal/websocket/ws.go:140 +0x45
github.com/surrealdb/surrealdb.go/internal/websocket.(*WebSocket).initialize.func1()
        /home/admin/go/pkg/mod/github.com/surrealdb/surrealdb.go@v0.2.1/internal/websocket/ws.go:167 +0xac
created by github.com/surrealdb/surrealdb.go/internal/websocket.(*WebSocket).initialize in goroutine 1
        /home/admin/go/pkg/mod/github.com/surrealdb/surrealdb.go@v0.2.1/internal/websocket/ws.go:160 +0x8e
exit status 2

Steps to reproduce

run an application and then stop surrealdb

Expected behaviour

reconnect or return back an error to the application, and let developer decide what to do

SurrealDB version

1.0.0+20230913.54aedcd for linux on x86_64

Contact Details

iliusha.md@gmail.com

Is there an existing issue for this?

Code of Conduct

ElecTwix commented 10 months ago

Thanks for the issue. As you said It needs to reconnect after the websocket connection is broken after other PRs merged I will look into this.

phughk commented 9 months ago

We do want a shared configuration between drivers about how we handle network traffic (timeouts, reconnects, circuiting breaking strategies etc). Overall this would need to be standardised but for now we could add a helper.

Would recommend adhering to existing golang standards.