Open
Description
System information
go-ethereum v1.10.8
OS & Version: linux
Expected behaviour
When using ethclient.Client.SubscribeFilterLogs
, all events matching the filter are caught.
Actual behaviour
After some time, the script stops reporting new events and it needs to be restarted to start working again.
Steps to reproduce the behaviour
var EthClient *ethclient.Client
// ...
currentBlock, _ := EthClient.BlockNumber(context.Background())
query := ethereum.FilterQuery{
Addresses: []common.Address{myAddress},
Topics: [][]common.Hash{{myTopic}},
FromBlock: big.NewInt(int64(currentBlock)),
}
logs := make(chan types.Log)
sub, err := EthClient.SubscribeFilterLogs(context.Background(), query, logs)
if err != nil {
log.Fatal(err)
return
}
for {
select {
case err := <-sub.Err():
log.Error(err)
continue
case vLog := <-logs:
event, err := MyContract.ParseSomeEvent(vLog)
if err != nil {
log.Error(err)
continue
}
// do something here with event
}
}
Hard for me to convey what needs to be done. I guess try to leave a script running for days and see if it stops catching new events after a while.
I'm not sure what could cause this issue. I automated script restart with cron to try to mitigate this issue but it still happens that the SubscribeFilterLogs
stops reporting new events.