From 5a0989489ea05997d24000713cb024ba7998bf8f Mon Sep 17 00:00:00 2001 From: "liu.zhen" Date: Wed, 18 Mar 2026 11:49:38 +0800 Subject: [PATCH] fix(client): increase timeout for file upload requests The default 30s HTTP client timeout is too short for file uploads, causing "context deadline exceeded" errors. Use a dedicated 5-minute timeout for the UploadFileContent method. Co-Authored-By: Claude Opus 4.6 (1M context) --- internal/client/client.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/internal/client/client.go b/internal/client/client.go index 176191c..3edbf06 100644 --- a/internal/client/client.go +++ b/internal/client/client.go @@ -16,6 +16,7 @@ const ( BaseURL = "https://api.notion.com" NotionVersion = "2022-06-28" DefaultTimeout = 30 * time.Second + UploadTimeout = 5 * time.Minute ) type Client struct { @@ -322,7 +323,10 @@ func (c *Client) UploadFileContent(uploadID, fileName, contentType string, fileB fmt.Printf("→ POST %s (multipart, %d bytes)\n", url, body.Len()) } + origTimeout := c.httpClient.Timeout + c.httpClient.Timeout = UploadTimeout resp, err := c.httpClient.Do(req) + c.httpClient.Timeout = origTimeout if err != nil { return nil, fmt.Errorf("upload request failed: %w", err) }