@@ -30,6 +30,8 @@ import (
3030const (
3131 jsRuntime = "js"
3232 goRuntime = "go"
33+
34+ preProcessingTimeout = time .Minute * 5
3335)
3436
3537type uploadType int
@@ -62,10 +64,11 @@ type DeployOptions struct {
6264
6365 IsDraft bool
6466
65- Title string
66- Branch string
67- CommitRef string
68- UploadTimeout time.Duration
67+ Title string
68+ Branch string
69+ CommitRef string
70+ UploadTimeout time.Duration
71+ PreProcessTimeout time.Duration
6972
7073 Observer DeployObserver
7174
@@ -237,7 +240,7 @@ func (n *Netlify) DoDeploy(ctx context.Context, options *DeployOptions, deploy *
237240
238241 if n .overCommitted (options .files ) {
239242 var err error
240- deploy , err = n .WaitUntilDeployReady (ctx , deploy )
243+ deploy , err = n .WaitUntilDeployReady (ctx , deploy , options . PreProcessTimeout )
241244 if err != nil {
242245 if options .Observer != nil {
243246 options .Observer .OnFailedDelta (deployFiles )
@@ -269,11 +272,15 @@ func (n *Netlify) DoDeploy(ctx context.Context, options *DeployOptions, deploy *
269272 return deploy , nil
270273}
271274
272- func (n * Netlify ) WaitUntilDeployReady (ctx context.Context , d * models.Deploy ) (* models.Deploy , error ) {
275+ func (n * Netlify ) WaitUntilDeployReady (ctx context.Context , d * models.Deploy , timeout time. Duration ) (* models.Deploy , error ) {
273276 authInfo := context .GetAuthInfo (ctx )
274277 ticker := time .NewTicker (2 * time .Second )
275278 defer ticker .Stop ()
276279
280+ if timeout <= 0 {
281+ timeout = preProcessingTimeout
282+ }
283+
277284 params := operations .NewGetSiteDeployParams ().WithSiteID (d .SiteID ).WithDeployID (d .ID )
278285 start := time .Now ()
279286 for t := range ticker .C {
@@ -295,7 +302,7 @@ func (n *Netlify) WaitUntilDeployReady(ctx context.Context, d *models.Deploy) (*
295302 return nil , fmt .Errorf ("Error: preprocessing deploy failed" )
296303 }
297304
298- if t .Sub (start ) > n . preProcessingTimeout {
305+ if t .Sub (start ) > timeout {
299306 return nil , fmt .Errorf ("Error: preprocessing deploy timed out" )
300307 }
301308 }
0 commit comments