provider: a check-in sent through a plugin's fetch that got no reply retries in a minute, not half an hour (plugins #149)
A moved WorkBuddy account's check-in goes through the plugin's fetch.
Bun's failure comes back as text, not as a *url.Error, so
wbCheckinFailed took "ECONNRESET: The socket connection was closed
unexpectedly" for a refusal and waited the full 30 minutes. It now also
treats Bun's and Node's words for a request that got no reply as
offline: ECONNRESET, ECONNREFUSED, ETIMEDOUT, ENOTFOUND, EAI_AGAIN,
EHOSTUNREACH, ENETUNREACH, ConnectionRefused, ConnectionClosed,
FailedToOpenSocket, "Unable to connect" and "socket connection was
closed unexpectedly". Offline retries after 1m, doubling, up to 30m.
wbCheckinFailed is the one place the workbuddy, minimax, qoder, trae and
plugin check-ins all go through.
TestWorkBuddyCheckinPluginResetRetriesSoon feeds the reporter's literal
error through the account's plugin fetch. The first tick is Failed and
Offline; a minute later the fetch answers and the tick is Claimed.
"plugin fetch: HTTP 500", "WorkBuddy refused: code 11140" and "Unable to
parse the reply" stay not offline. With the fix stashed the test is red
("reset: … Offline:false").
Run (sandbox HOME, GOMODCACHE, GOCACHE; set -o pipefail), base
e72b6a332:
- go test -tags nogui ./internal/provider -run Checkin: ok.
- gofmt -l: clean. GOOS=darwin, linux and windows go vet -tags nogui ./...:
ok.
- Full suite: go test -tags nogui -timeout 45m ./... at a load average of
190 to 300 (other sessions' suites): 63 ok, internal/provider ok
(865s). Not clean:
- Three failures from a full disk (ENOSPC) during the run.
- internal/library: passed on rerun (2345s).
- internal/agent and internal/gateway: timed out at 45m twice, with
tests seconds into their run at the cutoff. Rerun with -timeout 150m:
agent ok (5103s). Gateway was red only on
TestStreamErrorKeptOpenFailsOverAtOnce/chat/one_limited (4.0s
against 3s), which passes 3/3 alone; filed as #2570.
- TestIntentClassifierGroup's 3s bound (3.6s) is #1813, noted there.
Not run: a real WorkBuddy account with a connection reset.
This commit is contained in:
@@ -38,6 +38,7 @@ import (
|
||||
"net/http"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"slices"
|
||||
"sort"
|
||||
"strings"
|
||||
@@ -299,12 +300,19 @@ func wbCheckinRefused(err error) WorkBuddyCheckin {
|
||||
|
||||
// wbCheckinFailed is a check-in err kept from an answer: offline when the
|
||||
// request got no reply at all (no name lookup, no connection, no answer
|
||||
// in time), as a *url.Error from the client says.
|
||||
// in time), as a *url.Error from the client says, or, for a check-in sent
|
||||
// through a plugin's fetch, as Bun's words for it say: that comes back as
|
||||
// text, and a moved WorkBuddy account's "ECONNRESET: The socket connection
|
||||
// was closed unexpectedly" waited half an hour (plugins #149).
|
||||
func wbCheckinFailed(err error) WorkBuddyCheckin {
|
||||
var ne net.Error
|
||||
return WorkBuddyCheckin{Outcome: CheckinFailed, Msg: err.Error(), Offline: errors.As(err, &ne)}
|
||||
return WorkBuddyCheckin{Outcome: CheckinFailed, Msg: err.Error(), Offline: errors.As(err, &ne) || unanswered.MatchString(err.Error())}
|
||||
}
|
||||
|
||||
// unanswered is Bun's and Node's words for a fetch that got no reply: no
|
||||
// name lookup, no connection, or one closed before the answer.
|
||||
var unanswered = regexp.MustCompile(`\b(ECONNRESET|ECONNREFUSED|ETIMEDOUT|ENOTFOUND|EAI_AGAIN|EHOSTUNREACH|ENETUNREACH|ConnectionRefused|ConnectionClosed|FailedToOpenSocket)\b|Unable to connect|socket connection was closed unexpectedly`)
|
||||
|
||||
// CheckInWorkBuddy checks each WorkBuddy (China) account in use in for
|
||||
// today now, those not in yet, and says how each stands.
|
||||
func CheckInWorkBuddy(ctx context.Context) []WorkBuddyCheckin {
|
||||
|
||||
@@ -3,6 +3,7 @@ package provider
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"io"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
@@ -300,6 +301,47 @@ func TestWorkBuddyCheckinOfflineRetriesSoon(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// A moved account's check-in goes through the plugin's fetch, whose failure
|
||||
// comes back as Bun's text, not a net.Error. The connection reset that
|
||||
// plugins #149 showed is a check-in that never got an answer: tried again a
|
||||
// minute later, not half an hour. An answer that failed still waits.
|
||||
func TestWorkBuddyCheckinPluginResetRetriesSoon(t *testing.T) {
|
||||
f := &fakeWBCheckin{active: true}
|
||||
srv := f.serve(t)
|
||||
now := time.Date(2026, 3, 1, 2, 0, 0, 0, time.UTC)
|
||||
c := wbCheckinFixture(t, srv, &now)
|
||||
reset := true
|
||||
accts := c.accounts()
|
||||
accts[0].via = func(req *http.Request) (*http.Response, error) {
|
||||
if reset {
|
||||
// the reporter's words, as the plugin host passes them on
|
||||
return nil, errors.New("ECONNRESET: The socket connection was closed unexpectedly. For more information, pass `verbose: true` in the second argument to fetch()")
|
||||
}
|
||||
// the plugin signs it
|
||||
for k, v := range wbAuthHeaders(accts[0].site, accts[0].creds) {
|
||||
req.Header.Set(k, v)
|
||||
}
|
||||
return http.DefaultClient.Do(req)
|
||||
}
|
||||
c.accounts = func() []wbAccount { return accts }
|
||||
ctx := context.Background()
|
||||
var l wbCheckinLoop
|
||||
if rs := l.tick(ctx, c); len(rs) != 1 || rs[0].Outcome != CheckinFailed || !rs[0].Offline || !rs[0].Asked {
|
||||
t.Fatalf("reset: %+v", rs)
|
||||
}
|
||||
reset = false
|
||||
now = now.Add(time.Minute)
|
||||
if rs := l.tick(ctx, c); len(rs) != 1 || rs[0].Outcome != CheckinClaimed || !rs[0].Asked {
|
||||
t.Fatalf("a minute on: %+v", rs)
|
||||
}
|
||||
|
||||
for _, msg := range []string{"plugin fetch: HTTP 500", "WorkBuddy refused: code 11140", "Unable to parse the reply"} {
|
||||
if r := wbCheckinFailed(errors.New(msg)); r.Offline {
|
||||
t.Errorf("%q read as never answered", msg)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// The accounts are WorkBuddy's own sign-in and those magpie added, read as
|
||||
// the rest of magpie reads them; what is kept is shown by name.
|
||||
func TestWorkBuddyCheckinSignedIn(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user