Add context timeouts for third-party requests
Some checks failed
/ golint (push) Failing after 3m56s

Avoid hanging a goroutine for a long time.
This commit is contained in:
Eli Ribble 2026-05-19 00:24:16 +00:00
parent 2093ea74c4
commit 15d8966971
No known key found for this signature in database
11 changed files with 80 additions and 5 deletions

View file

@ -3,6 +3,7 @@ package pdf
import (
"context"
"fmt"
"time"
"github.com/Gleipnir-Technology/nidus-sync/config"
"github.com/chromedp/cdproto/page"
@ -13,7 +14,9 @@ import (
func GeneratePDF(ctx context.Context, path string) ([]byte, error) {
// create context
chromedp.Env("CHROME_FLAGS=--no-sandbox --disable-gpu --disable-dev-shm-usage")
chrome_ctx, cancel := chromedp.NewContext(context.Background())
chromeCtx, chromeCancel := context.WithTimeout(context.Background(), 60*time.Second)
defer chromeCancel()
chrome_ctx, cancel := chromedp.NewContext(chromeCtx)
defer cancel()
// capture pdf