From 9ec8a88cb023116a237b28e797f32ce986fcabf5 Mon Sep 17 00:00:00 2001 From: jochen Date: Sat, 14 Nov 2026 16:17:14 +0100 Subject: [PATCH] A call nobody answered names the subjects it was asked on and how long it waited, so its caller's log says where it went unanswered (operator, 2026-11-14: add logging) --- go/process/call.go | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/go/process/call.go b/go/process/call.go index b1ad9e9e..407ebd59 100644 --- a/go/process/call.go +++ b/go/process/call.go @@ -108,14 +108,36 @@ func callKeptWith(request func(string, []byte) (json.RawMessage, error), called, func askBoth(request func(string, []byte) (json.RawMessage, error), called, fallback string, data []byte) func() (json.RawMessage, error) { return func() (json.RawMessage, error) { + start := time.Now() result, err := request(called, data) - if errors.Is(err, nats.ErrNoResponders) { - result, err = request(fallback, data) + if !errors.Is(err, nats.ErrNoResponders) { + return result, unansweredOn(err, start, called) + } + first := err + start2 := time.Now() + result, err = request(fallback, data) + if err != nil && !isAnswered(err) { + return result, fmt.Errorf("asked on %s (%v), then on %s, unanswered after %s: %w", called, first, fallback, + time.Since(start2).Round(time.Millisecond), err) } return result, err } } +// unansweredOn names the subject a transport fault was met on and how long it waited, so a log of a call nobody +// answered says where it was asked; a callee's answer keeps its own words. +func unansweredOn(err error, start time.Time, subject string) error { + if err == nil || isAnswered(err) { + return err + } + return fmt.Errorf("asked on %s, unanswered after %s: %w", subject, time.Since(start).Round(time.Millisecond), err) +} + +func isAnswered(err error) bool { + var a *busretry.Answered + return errors.As(err, &a) +} + // callOn asks called, then fallback when nothing answers it; while the bus itself answers nothing (a user-list reload // drops the account's imports for a few seconds, busretry) both are asked again, within busretry.Bound. A call nobody // answers on a bus that answers is not asked again: its callee is not running. A call that may have been delivered (a