Files
buildkit/session/context.go
Tonis Tiigi 70b363e54c session: fail stuck session RPCs on health timeout
Bind session RPC contexts to caller lifetime so ongoing RPCs fail when the
session is canceled. Add an integration test that blocks the session tunnel
and verifies the health monitor releases the hung build after timeout.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2026-04-02 23:29:16 -07:00

18 lines
463 B
Go

package session
import "context"
// contextWithCaller returns a context that is canceled when either the request
// context is done or the session context is closed.
func contextWithCaller(ctx context.Context, callerCtx context.Context) context.Context {
ctx, cancel := context.WithCancelCause(ctx)
context.AfterFunc(callerCtx, func() {
cause := context.Cause(callerCtx)
if cause == nil {
cause = context.Canceled
}
cancel(cause)
})
return ctx
}