uber-go/fx

handle error formatting on `context.DeadlineExceeded` from hooks using fxevent

distractedm1nd opened this issue · 1 comments

When the context exceeds a deadline during OnStart, the stack trace is added to the error passed up.

fx/app.go

Lines 778 to 788 in fa108cc

// TODO: Once this is integrated into fxevent, we can
// leave error unchanged and send this to fxevent.Logger, whose
// implementation can then determine how the error is presented.
if len(r) > 0 {
sort.Sort(r)
return fmt.Errorf("%v hook added by %v failed: %w\n%+v",
param.hook,
caller,
err,
r)
}

If I understand correctly, the linked code is where this wrapping occurs, and the preferred solution is to let fxevent handle the display of the error.

We recently came across this when trying to suppress the stack trace in an error during startup celestiaorg/celestia-node#1458. The stack trace is pretty scary for users, and doesn't appear on other startup errors that don't exceed a context deadline.

would be happy to assist with a PR, but can't judge how big the scope would be yet, so I will wait for some feedback first :)