internal/pkg: discontinue DCE resolution on signal
All checks were successful
Test / Create distribution (push) Successful in 1m4s
Test / Sandbox (push) Successful in 2m47s
Test / ShareFS (push) Successful in 3m45s
Test / Hakurei (push) Successful in 3m53s
Test / Sandbox (race detector) (push) Successful in 5m22s
Test / Hakurei (race detector) (push) Successful in 6m24s
Test / Flake checks (push) Successful in 1m28s
All checks were successful
Test / Create distribution (push) Successful in 1m4s
Test / Sandbox (push) Successful in 2m47s
Test / ShareFS (push) Successful in 3m45s
Test / Hakurei (push) Successful in 3m53s
Test / Sandbox (race detector) (push) Successful in 5m22s
Test / Hakurei (race detector) (push) Successful in 6m24s
Test / Flake checks (push) Successful in 1m28s
This serves as a stopgap measure to skip long-running DCE resolutions. Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
@@ -15,6 +15,7 @@ import (
|
|||||||
"io/fs"
|
"io/fs"
|
||||||
"maps"
|
"maps"
|
||||||
"os"
|
"os"
|
||||||
|
"os/signal"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
"slices"
|
"slices"
|
||||||
@@ -1500,16 +1501,21 @@ type DependencyCureError []*CureError
|
|||||||
|
|
||||||
// unwrapM recursively expands underlying errors into a caller-supplied map.
|
// unwrapM recursively expands underlying errors into a caller-supplied map.
|
||||||
func (e *DependencyCureError) unwrapM(
|
func (e *DependencyCureError) unwrapM(
|
||||||
|
ctx context.Context,
|
||||||
ir *IRCache,
|
ir *IRCache,
|
||||||
me map[unique.Handle[ID]]*CureError,
|
me map[unique.Handle[ID]]*CureError,
|
||||||
) {
|
) {
|
||||||
for _, err := range *e {
|
for _, err := range *e {
|
||||||
|
if ctx.Err() != nil {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
id := ir.Ident(err.A)
|
id := ir.Ident(err.A)
|
||||||
if _, ok := me[id]; ok {
|
if _, ok := me[id]; ok {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if _e, ok := err.Err.(*DependencyCureError); ok {
|
if _e, ok := err.Err.(*DependencyCureError); ok {
|
||||||
_e.unwrapM(ir, me)
|
_e.unwrapM(ctx, ir, me)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
me[id] = err
|
me[id] = err
|
||||||
@@ -1517,9 +1523,12 @@ func (e *DependencyCureError) unwrapM(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// unwrap recursively expands and deduplicates underlying errors.
|
// unwrap recursively expands and deduplicates underlying errors.
|
||||||
func (e *DependencyCureError) unwrap(ir *IRCache) DependencyCureError {
|
func (e *DependencyCureError) unwrap(
|
||||||
|
ctx context.Context,
|
||||||
|
ir *IRCache,
|
||||||
|
) DependencyCureError {
|
||||||
me := make(map[unique.Handle[ID]]*CureError)
|
me := make(map[unique.Handle[ID]]*CureError)
|
||||||
e.unwrapM(ir, me)
|
e.unwrapM(ctx, ir, me)
|
||||||
type ent struct {
|
type ent struct {
|
||||||
id unique.Handle[ID]
|
id unique.Handle[ID]
|
||||||
err *CureError
|
err *CureError
|
||||||
@@ -1544,7 +1553,10 @@ func (e *DependencyCureError) unwrap(ir *IRCache) DependencyCureError {
|
|||||||
|
|
||||||
// Unwrap returns a deduplicated slice of underlying errors.
|
// Unwrap returns a deduplicated slice of underlying errors.
|
||||||
func (e *DependencyCureError) Unwrap() []error {
|
func (e *DependencyCureError) Unwrap() []error {
|
||||||
errs := e.unwrap(NewIR())
|
ctx, cancel := signal.NotifyContext(context.Background(), os.Interrupt)
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
|
errs := e.unwrap(ctx, NewIR())
|
||||||
_errs := make([]error, len(errs))
|
_errs := make([]error, len(errs))
|
||||||
for i, err := range errs {
|
for i, err := range errs {
|
||||||
_errs[i] = err
|
_errs[i] = err
|
||||||
@@ -1554,8 +1566,11 @@ func (e *DependencyCureError) Unwrap() []error {
|
|||||||
|
|
||||||
// Error returns a user-facing multiline error message.
|
// Error returns a user-facing multiline error message.
|
||||||
func (e *DependencyCureError) Error() string {
|
func (e *DependencyCureError) Error() string {
|
||||||
|
ctx, cancel := signal.NotifyContext(context.Background(), os.Interrupt)
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
ir := NewIR()
|
ir := NewIR()
|
||||||
errs := e.unwrap(ir)
|
errs := e.unwrap(ctx, ir)
|
||||||
if len(errs) == 0 {
|
if len(errs) == 0 {
|
||||||
return "invalid dependency cure outcome"
|
return "invalid dependency cure outcome"
|
||||||
}
|
}
|
||||||
@@ -1566,6 +1581,9 @@ func (e *DependencyCureError) Error() string {
|
|||||||
reportName(err.A, ir.Ident(err.A)) + ": " +
|
reportName(err.A, ir.Ident(err.A)) + ": " +
|
||||||
err.Error())
|
err.Error())
|
||||||
}
|
}
|
||||||
|
if ctx.Err() != nil {
|
||||||
|
buf.WriteString("\nerror resolution cancelled")
|
||||||
|
}
|
||||||
return buf.String()
|
return buf.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user