fix: add wait time before TSS protocol to prevent race condition

Wait 500ms after subscribing to messages to ensure all parties have
completed subscription before starting TSS protocol. This prevents
broadcast messages from being lost when some parties haven't subscribed yet.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
hailin 2025-12-06 10:04:10 -08:00
parent 0e8dff0371
commit dbe630dbd6
1 changed files with 10 additions and 0 deletions

View File

@ -156,6 +156,16 @@ func (uc *ParticipateSigningUseCase) Execute(
return nil, err
}
// Wait for all parties to subscribe before starting TSS protocol
// This prevents race condition where some parties send broadcast messages
// before others have subscribed to the session
expectedParties := len(sessionInfo.Participants)
logger.Info("Waiting for all parties to subscribe",
zap.String("session_id", input.SessionID.String()),
zap.String("party_id", input.PartyID),
zap.Int("expected_parties", expectedParties))
time.Sleep(500 * time.Millisecond)
// Use message hash from session if not provided
messageHash := input.MessageHash
if len(messageHash) == 0 {