Rework telegram client lifecycle to hopefully fix not stopping issues (#112)

This commit is contained in:
Adam Van Ymeren
2025-07-17 09:56:11 -04:00
committed by GitHub
parent b16061db34
commit e9abeda916
6 changed files with 132 additions and 144 deletions
+3 -10
View File
@@ -220,16 +220,9 @@ func parseRandomID(txnID networkid.RawTransactionID) int64 {
func (t *TelegramClient) HandleMatrixMessage(ctx context.Context, msg *bridgev2.MatrixMessage) (resp *bridgev2.MatrixMessageResponse, err error) {
// Handle Matrix events only after initial connection has been established to avoid deadlocking gotd
select {
case <-t.initialized:
default:
zerolog.Ctx(ctx).Warn().Msg("Got Matrix event before connected, blocking until done")
select {
case <-t.initialized:
case <-ctx.Done():
return nil, ctx.Err()
}
err = t.clientInitialized.Wait(ctx)
if err != nil {
return nil, err
}
peer, err := t.inputPeerForPortalID(ctx, msg.Portal.ID)