Skip to content

Commit

Permalink
go/packages: avoid logging context canceled error
Browse files Browse the repository at this point in the history
If the context is canceled for packages.Load, the following log message is
written numerous times (spammed) to stderr:

internal error: error "context canceled" (*errors.errorString) without position

Check if the error is context.Canceled and don't log it if so.

The error will still be recorded in lpkg.Errors.

Signed-off-by: Christian Stewart <christian@aperture.us>
  • Loading branch information
paralin committed Mar 12, 2024
1 parent ca94c96 commit 96ea3e4
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion go/packages/packages.go
Expand Up @@ -921,7 +921,9 @@ func (ld *loader) loadPackage(lpkg *loaderPackage) {
})

// If you see this error message, please file a bug.
log.Printf("internal error: error %q (%T) without position", err, err)
if err != context.Canceled {
log.Printf("internal error: error %q (%T) without position", err, err)
}
}

lpkg.Errors = append(lpkg.Errors, errs...)
Expand Down

0 comments on commit 96ea3e4

Please sign in to comment.