mirror of
https://github.com/priyanshujain/sanderling.git
synced 2026-10-02 11:07:10 +00:00
fix(ioscompanion): classify connection deadline expiry as caller budget
This commit is contained in:
1 parent
a8ba0d3873
commit
665d757dce
1 file changed
+8
-2
@@ -8,6 +8,7 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"net"
|
||||
"os"
|
||||
"os/exec"
|
||||
"sync"
|
||||
"time"
|
||||
@@ -132,13 +133,18 @@ func (c *runnerCompanion) call(ctx context.Context, method string, params map[st
|
||||
// wrapTransport classifies a read/write failure. A caller-imposed cancel or
|
||||
// deadline is the caller's slowness budget, not a connection loss, so it does
|
||||
// not carry the unavailable sentinel: a child restart would not make the call
|
||||
// faster. Either way the connection is desynced and reconnects on the next
|
||||
// call.
|
||||
// faster. The connection's own deadline is only ever set from the caller's
|
||||
// context, so a deadline-exceeded network error is the same budget expiry
|
||||
// even when it beats the context's done flag by a hair. Either way the
|
||||
// connection is desynced and reconnects on the next call.
|
||||
func (c *runnerCompanion) wrapTransport(ctx context.Context, stage, method string, err error) error {
|
||||
c.dirty = true
|
||||
if ctxErr := ctx.Err(); ctxErr != nil {
|
||||
return fmt.Errorf("runner %s interrupted (%s): %w", method, stage, ctxErr)
|
||||
}
|
||||
if errors.Is(err, os.ErrDeadlineExceeded) {
|
||||
return fmt.Errorf("runner %s interrupted (%s): %w", method, stage, err)
|
||||
}
|
||||
return fmt.Errorf("runner transport: %w: %s %s: %v", ErrCompanionUnavailable, stage, method, err)
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user