It happens that the keep-core client panics when interacting with the go-electrum library. We noticed a "concurrent write to websocket connection" error was thrown when calling GetLatestBlockHeight() function. The stack trace leads to gorilla/websocket/WriteMessage which is called from the go-electrum library. The latest block height call was already wrapped with a read mutex, but we should also wrap it with the write mutex to prevent such concurrent errors.
~I wasn't able to recreate the concurrent write to websocket connection error in the integration tests.~
I've added an integration test that hit the GetLatestBlockHeight() concurrently. Without the W lock I was able to replicate the same panic. cab1168 fixed it.
Refs https://github.com/keep-network/keep-core/issues/3699
Depends on https://github.com/keep-network/keep-core/pull/3704
It happens that the keep-core client panics when interacting with the
go-electrum
library. We noticed a "concurrent write to websocket connection" error was thrown when callingGetLatestBlockHeight()
function. The stack trace leads to gorilla/websocket/WriteMessage which is called from thego-electrum
library. The latest block height call was already wrapped with a read mutex, but we should also wrap it with the write mutex to prevent such concurrent errors.