@@ -106,8 +106,8 @@ func (c *Client) solve(ctx context.Context, def *llb.Definition, runGateway runG
106106 }
107107 eg , ctx := errgroup .WithContext (ctx )
108108
109- statusContext , cancelStatus := context .WithCancel (context .Background ())
110- defer cancelStatus ()
109+ statusContext , cancelStatus := context .WithCancelCause (context .Background ())
110+ defer cancelStatus (errors . WithStack ( context . Canceled ) )
111111
112112 if span := trace .SpanFromContext (ctx ); span .SpanContext ().IsValid () {
113113 statusContext = trace .ContextWithSpan (statusContext , span )
@@ -230,16 +230,16 @@ func (c *Client) solve(ctx context.Context, def *llb.Definition, runGateway runG
230230 frontendAttrs [k ] = v
231231 }
232232
233- solveCtx , cancelSolve := context .WithCancel (ctx )
233+ solveCtx , cancelSolve := context .WithCancelCause (ctx )
234234 var res * SolveResponse
235235 eg .Go (func () error {
236236 ctx := solveCtx
237- defer cancelSolve ()
237+ defer cancelSolve (errors . WithStack ( context . Canceled ) )
238238
239239 defer func () { // make sure the Status ends cleanly on build errors
240240 go func () {
241241 <- time .After (3 * time .Second )
242- cancelStatus ()
242+ cancelStatus (errors . WithStack ( context . Canceled ) )
243243 }()
244244 if ! opt .SessionPreInitialized {
245245 bklog .G (ctx ).Debugf ("stopping session" )
@@ -298,7 +298,7 @@ func (c *Client) solve(ctx context.Context, def *llb.Definition, runGateway runG
298298 select {
299299 case <- solveCtx .Done ():
300300 case <- time .After (5 * time .Second ):
301- cancelSolve ()
301+ cancelSolve (errors . WithStack ( context . Canceled ) )
302302 }
303303
304304 return err
0 commit comments