fix: add 30s timeouts to account.go goroutines using context.Background()
CI / Env docs check (push) Successful in 13s
CI / Nginx config check (push) Successful in 20s
CI / Docker compose check (push) Successful in 20s
CI / Frontend major deps (push) Successful in 22s
CI / Frontend deps check (push) Successful in 28s
CI / Secrets scan (push) Successful in 41s
CI / Go build (push) Successful in 40s
CI / Frontend build (push) Successful in 43s
CI / Knip (push) Successful in 46s
CI / Go vet (prod) (push) Successful in 1m45s
CI / Frontend a11y check (push) Successful in 2m7s
CI / Go vet (dev) (push) Successful in 1m58s
CI / go mod tidy (push) Successful in 35s
CI / Frontend QC (audit) (push) Successful in 39s
CI / Staticcheck (prod) (push) Successful in 2m44s
CI / Go vulnerabilities (push) Successful in 1m46s
CI / Staticcheck (dev) (push) Successful in 3m45s
CI / golangci-lint (push) Successful in 3m47s
CI / Frontend QC (typecheck) (push) Successful in 1m43s
CI / Security scan (dev) (push) Successful in 4m8s
CI / Security scan (prod) (push) Successful in 3m51s
CI / Frontend QC (lint) (push) Successful in 1m53s
CI / Svelte strict check (push) Successful in 58s
CI / Tests (prod) (push) Successful in 3m15s
CI / Tests (dev) (push) Successful in 3m39s
CI / Race (prod) (push) Successful in 6m50s
CI / Race (dev) (push) Successful in 7m6s

This commit is contained in:
2026-07-11 17:10:11 +01:00
parent 0afa642a10
commit 11fbf869e1
2 changed files with 9 additions and 3 deletions
+8 -3
View File
@@ -9,6 +9,7 @@ import (
"log/slog"
"net/http"
"os"
"time"
"crussell/db"
"crussell/handlers/payments"
@@ -53,13 +54,15 @@ func DeleteAccountHandler(w http.ResponseWriter, r *http.Request) {
log.Printf("Panic recovered in S3 profile picture deletion: %v", r)
}
}()
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
defer cancel()
bucket := os.Getenv("S3_PROFILE_PICS_BUCKET")
if bucket == "" {
bucket = "crussell-profile-pics"
}
// profiles/{userID}.jpg — matches UploadProfilePictureHandler key format
key := fmt.Sprintf("profiles/%s.jpg", userID)
if err := s3.Client.Delete(context.Background(), bucket, key); err != nil {
if err := s3.Client.Delete(ctx, bucket, key); err != nil {
log.Printf("Warning: Failed to delete profile picture for user %s: %v", userID, err)
}
}(profilePicURL.String)
@@ -73,7 +76,9 @@ func DeleteAccountHandler(w http.ResponseWriter, r *http.Request) {
log.Printf("Panic recovered in Square saved card cleanup: %v", r)
}
}()
rows, err := db.Conn.Query(context.Background(),
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
defer cancel()
rows, err := db.Conn.Query(ctx,
`SELECT square_card_id FROM user_saved_cards WHERE user_id = $1 AND deleted_at IS NULL`, userID)
if err != nil {
log.Printf("Warning: Failed to query saved cards for user %s: %v", userID, err)
@@ -86,7 +91,7 @@ func DeleteAccountHandler(w http.ResponseWriter, r *http.Request) {
log.Printf("Warning: Failed to scan card ID for user %s: %v", userID, err)
continue
}
if err := payments.SquareClient.DeleteCardOnFile(context.Background(), cardID); err != nil {
if err := payments.SquareClient.DeleteCardOnFile(ctx, cardID); err != nil {
log.Printf("Warning: Failed to delete Square card %s for user %s: %v", cardID, userID, err)
}
}