Closed thp-canonical closed 6 months ago
Instead of ignoring the error from reaper.Stop in the last case, how about we just log the reaper.Stop error in all cases? It's during shutdown in any case, so it doesn't actually matter as things will get cleaned up (though currently reaper.Stop never returns an error). Can we do this?
Sounds reasonable, PR updated - thanks! :)
@thp-canonical Looks like you just need to replace %w with %v in the logger call to fix the tests.
PR #380 recently changed the way the reaper is stopped.
If
runDaemon()
returns an error thedefer
method overwrites theerr
return value inerr = reaper.Stop()
. Iferr
was already set to something else, this will in effect overwrite the non-nil
err
with eithernil
(ifreaper.Stop()
returnsnil
) or a different error (ifreaper.Stop()
returns a different error).Currently (without this PR):
err == nil
on defer method entry,reaper.Stop()
returnsnil
- that's okay (no error)err == nil
on defer method entry,reaper.Stop()
returns non-nil
- that's okay (reaper error reported)err != nil
on defer method entry,reaper.Stop()
returnsnil
-err
overwritten,runDaemon
errorneously returns successerr != nil
on defer method entry,reaper.Stop()
return non-nil
-err
overwritten,runDaemon
returns an error properly, but the real error is overwritten by the reaper error messageWith this PR:
err == nil
on defer method entry,reaper.Stop()
returnsnil
- that's okay (no error)err == nil
on defer method entry,reaper.Stop()
returns non-nil
- that's okay (reaper error reported)err != nil
on defer method entry,reaper.Stop()
returnsnil
-err
is returned properlyerr != nil
on defer method entry,reaper.Stop()
return non-nil
-err
is returned, the error fromreaper.Stop()
is hidden / ignoredBecause this defer method is the first one in the function, it will get called last, so it's the one that will have
err
set on entry if the function returns a non-nil
error.