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

This serves as a stopgap measure to skip long-running DCE resolutions.

Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
2026-05-13 00:28:04 +09:00
parent 487a03b5a3
commit 4bede7ecdd

View File

@@ -15,6 +15,7 @@ import (
"io/fs"
"maps"
"os"
"os/signal"
"path/filepath"
"runtime"
"slices"
@@ -1500,16 +1501,21 @@ type DependencyCureError []*CureError
// unwrapM recursively expands underlying errors into a caller-supplied map.
func (e *DependencyCureError) unwrapM(
ctx context.Context,
ir *IRCache,
me map[unique.Handle[ID]]*CureError,
) {
for _, err := range *e {
if ctx.Err() != nil {
break
}
id := ir.Ident(err.A)
if _, ok := me[id]; ok {
continue
}
if _e, ok := err.Err.(*DependencyCureError); ok {
_e.unwrapM(ir, me)
_e.unwrapM(ctx, ir, me)
continue
}
me[id] = err
@@ -1517,9 +1523,12 @@ func (e *DependencyCureError) unwrapM(
}
// 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)
e.unwrapM(ir, me)
e.unwrapM(ctx, ir, me)
type ent struct {
id unique.Handle[ID]
err *CureError
@@ -1544,7 +1553,10 @@ func (e *DependencyCureError) unwrap(ir *IRCache) DependencyCureError {
// Unwrap returns a deduplicated slice of underlying errors.
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))
for i, err := range errs {
_errs[i] = err
@@ -1554,8 +1566,11 @@ func (e *DependencyCureError) Unwrap() []error {
// Error returns a user-facing multiline error message.
func (e *DependencyCureError) Error() string {
ctx, cancel := signal.NotifyContext(context.Background(), os.Interrupt)
defer cancel()
ir := NewIR()
errs := e.unwrap(ir)
errs := e.unwrap(ctx, ir)
if len(errs) == 0 {
return "invalid dependency cure outcome"
}
@@ -1566,6 +1581,9 @@ func (e *DependencyCureError) Error() string {
reportName(err.A, ir.Ident(err.A)) + ": " +
err.Error())
}
if ctx.Err() != nil {
buf.WriteString("\nerror resolution cancelled")
}
return buf.String()
}