From 63e16a79b2f73c6c8a5b68adcca3de80276a6050 Mon Sep 17 00:00:00 2001 From: oppiliappan Date: Tue, 2 Dec 2025 10:30:21 +0000 Subject: [PATCH] appview/oauth: allow customizing client timeouts in xrpc reqs Change-Id: zowxpuywkwnvmqrrvzylostnmyrtoxmu Signed-off-by: oppiliappan --- appview/oauth/oauth.go | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/appview/oauth/oauth.go b/appview/oauth/oauth.go index cc1245a9..8e94fc23 100644 --- a/appview/oauth/oauth.go +++ b/appview/oauth/oauth.go @@ -202,10 +202,17 @@ type ServiceClientOpts struct { exp int64 lxm string dev bool + timeout time.Duration } type ServiceClientOpt func(*ServiceClientOpts) +func DefaultServiceClientOpts() ServiceClientOpts { + return ServiceClientOpts{ + timeout: time.Second * 5, + } +} + func WithService(service string) ServiceClientOpt { return func(s *ServiceClientOpts) { s.service = service @@ -233,6 +240,12 @@ func WithDev(dev bool) ServiceClientOpt { } } +func WithTimeout(timeout time.Duration) ServiceClientOpt { + return func(s *ServiceClientOpts) { + s.timeout = timeout + } +} + func (s *ServiceClientOpts) Audience() string { return fmt.Sprintf("did:web:%s", s.service) } @@ -247,7 +260,7 @@ func (s *ServiceClientOpts) Host() string { } func (o *OAuth) ServiceClient(r *http.Request, os ...ServiceClientOpt) (*xrpc.Client, error) { - opts := ServiceClientOpts{} + opts := DefaultServiceClientOpts() for _, o := range os { o(&opts) } @@ -274,7 +287,7 @@ func (o *OAuth) ServiceClient(r *http.Request, os ...ServiceClientOpt) (*xrpc.Cl }, Host: opts.Host(), Client: &http.Client{ - Timeout: time.Second * 5, + Timeout: opts.timeout, }, }, nil } -- 2.43.0 From 782024a3256cda013aca54cd0d125396aefe3a7e Mon Sep 17 00:00:00 2001 From: oppiliappan Date: Tue, 2 Dec 2025 10:30:21 +0000 Subject: [PATCH] appview/repo: bump request timeout for fork creation Change-Id: tzszvtloukvmqstlypntmylwytpxsqto this requires a bare clone; which could take time depending on the size of the repo. Signed-off-by: oppiliappan --- appview/repo/repo.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/appview/repo/repo.go b/appview/repo/repo.go index 3af02177..4ba4cf5c 100644 --- a/appview/repo/repo.go +++ b/appview/repo/repo.go @@ -1130,11 +1130,13 @@ func (rp *Repo) ForkRepo(w http.ResponseWriter, r *http.Request) { } defer rollback() + // TODO: this could coordinate better with the knot to recieve a clone status client, err := rp.oauth.ServiceClient( r, oauth.WithService(targetKnot), oauth.WithLxm(tangled.RepoCreateNSID), oauth.WithDev(rp.config.Core.Dev), + oauth.WithTimeout(time.Second*20), // big repos take time to clone ) if err != nil { l.Error("could not create service client", "err", err) -- 2.43.0