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
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:
@@ -1,6 +1,7 @@
|
|||||||
package payments
|
package payments
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"database/sql"
|
"database/sql"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import (
|
|||||||
"log/slog"
|
"log/slog"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
|
"time"
|
||||||
|
|
||||||
"crussell/db"
|
"crussell/db"
|
||||||
"crussell/handlers/payments"
|
"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)
|
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")
|
bucket := os.Getenv("S3_PROFILE_PICS_BUCKET")
|
||||||
if bucket == "" {
|
if bucket == "" {
|
||||||
bucket = "crussell-profile-pics"
|
bucket = "crussell-profile-pics"
|
||||||
}
|
}
|
||||||
// profiles/{userID}.jpg — matches UploadProfilePictureHandler key format
|
// profiles/{userID}.jpg — matches UploadProfilePictureHandler key format
|
||||||
key := fmt.Sprintf("profiles/%s.jpg", userID)
|
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)
|
log.Printf("Warning: Failed to delete profile picture for user %s: %v", userID, err)
|
||||||
}
|
}
|
||||||
}(profilePicURL.String)
|
}(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)
|
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)
|
`SELECT square_card_id FROM user_saved_cards WHERE user_id = $1 AND deleted_at IS NULL`, userID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("Warning: Failed to query saved cards for user %s: %v", userID, err)
|
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)
|
log.Printf("Warning: Failed to scan card ID for user %s: %v", userID, err)
|
||||||
continue
|
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)
|
log.Printf("Warning: Failed to delete Square card %s for user %s: %v", cardID, userID, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user