1
0
mirror of https://github.com/moby/buildkit.git synced 2025-08-08 10:02:07 +03:00

improve stacks of cancels from defers

In this case the current stack trace points to the line
where the context was created. Instead the stack should be
captured when the defer is running so the return path to
the defer call is also part of the stack.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
This commit is contained in:
Tonis Tiigi
2024-11-19 18:40:00 -08:00
parent ab83f87af8
commit e05a89e0b8
25 changed files with 28 additions and 28 deletions

View File

@@ -143,7 +143,7 @@ func (ls *localSourceHandler) Snapshot(ctx context.Context, g session.Group) (ca
timeoutCtx, cancel := context.WithCancelCause(ctx)
timeoutCtx, _ = context.WithTimeoutCause(timeoutCtx, 5*time.Second, errors.WithStack(context.DeadlineExceeded))
defer cancel(errors.WithStack(context.Canceled))
defer func() { cancel(errors.WithStack(context.Canceled)) }()
caller, err := ls.sm.Get(timeoutCtx, sessionID, false)
if err != nil {