surrealdb.go
surrealdb.go copied to clipboard
Bug: Re-connection to the DB
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/[email protected]/conn.go:1030 +0x4f4
github.com/gorilla/websocket.(*Conn).ReadMessage(0x129dfa0?)
/home/admin/go/pkg/mod/github.com/gorilla/[email protected]/conn.go:1093 +0x2f
github.com/surrealdb/surrealdb.go/internal/websocket.(*WebSocket).read(0xc00039c080, {0xca5720, 0xc0003f4480})
/home/admin/go/pkg/mod/github.com/surrealdb/[email protected]/internal/websocket/ws.go:140 +0x45
github.com/surrealdb/surrealdb.go/internal/websocket.(*WebSocket).initialize.func1()
/home/admin/go/pkg/mod/github.com/surrealdb/[email protected]/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/[email protected]/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
Is there an existing issue for this?
- [X] I have searched the existing issues
Code of Conduct
- [X] I agree to follow this project's Code of Conduct
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.
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.