fix(server-party): use parent context in event handler for proper cancellation

- Fixed server-party event handler to use parent context with timeout
- Prevents orphan goroutines when session fails or party exits
- Consistent with server-party-api fix
This commit is contained in:
hailin 2025-12-06 06:39:23 -08:00
parent 450163a94d
commit 99ff3ac130
1 changed files with 5 additions and 3 deletions

View File

@ -568,7 +568,9 @@ func createSessionEventHandler(
// Automatically participate based on session type
go func() {
ctx := context.Background()
// Use parent context to allow proper cancellation
participateCtx, cancel := context.WithTimeout(ctx, 5*time.Minute)
defer cancel()
// Determine session type from event
if event.EventType == "session_created" {
@ -585,7 +587,7 @@ func createSessionEventHandler(
JoinToken: joinToken,
}
result, err := participateKeygenUC.Execute(ctx, input)
result, err := participateKeygenUC.Execute(participateCtx, input)
if err != nil {
logger.Error("Keygen participation failed",
zap.Error(err),
@ -617,7 +619,7 @@ func createSessionEventHandler(
zap.Int32("party_index", event.DelegateUserShare.PartyIndex))
}
result, err := participateSigningUC.Execute(ctx, input)
result, err := participateSigningUC.Execute(participateCtx, input)
if err != nil {
logger.Error("Signing participation failed",
zap.Error(err),