You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
i am using gsrpc in a project and noticed that a race occurs when trying to unsubscribe from a StorageSubscription while a second one is running.
This is weird since i never spawned a go-routine myself.
Place the following test in main_test.go and execute go test -v -count=1 -race -run=TestClient_Subscribe .:
funcTestClient_Subscribe(t*testing.T) {
// Setup and chain connectionapi, err:=gsrpc.NewSubstrateAPI(config.Default().RPCURL)
require.NoError(t, err)
meta, err:=api.RPC.State.GetMetadataLatest()
require.NoError(t, err)
// Use "Time" if you run an older node version.key, err:=types.CreateStorageKey(meta, "Timestamp", "Now")
require.NoError(t, err)
// Subscribe oncesub1, err:=api.RPC.State.SubscribeStorageRaw([]types.StorageKey{key})
require.NoError(t, err)
// Subscribe twice_, err=api.RPC.State.SubscribeStorageRaw([]types.StorageKey{key})
require.NoError(t, err)
// Unsubscribing produces a race!sub1.Unsubscribe()
}
Test output: race.txt.
The problem seems to occur between
No, we just refrained from running the race tests in our project…
I saw that this is old code copied from geth, maybe it could help to update it? I dont know.
Instead it could also use a fork as subrepo here, to keep track which files were changed from the geth code. @NunoAlexandre
Hi there,
i am using
gsrpc
in a project and noticed that a race occurs when trying to unsubscribe from aStorageSubscription
while a second one is running.This is weird since i never spawned a go-routine myself.
Place the following test in
main_test.go
and executego test -v -count=1 -race -run=TestClient_Subscribe .
:Test output: race.txt.
The problem seems to occur between
go-substrate-rpc-client/gethrpc/subscription.go
Line 304 in fee0d0e
go-substrate-rpc-client/rpc/state/subscribe_storage.go
Line 59 in 03ce7c5
Any help with this would be much appreciated, thanks for your time 🙏
The text was updated successfully, but these errors were encountered: