Files
magpie/internal/gateway/gateway_hook_test.go
T
yetoneandTsukikage7 9b04c4e20f plugin: async gateway request hooks, run in Bun before routing and after the reply (#2118)
A package's magpie.hooks entry (or a *.hooks.{js,mjs,ts,mts} file) exports
`async onRequest(body, ctx)` and an optional `onResponse(reply, ctx)`. They
run in the Bun plugin host, so a hook can await I/O, for example a context
service like PowerContext, which the sync moejs middleware can't. The
gateway still makes one model request per client request. A hook adds
context to the body; it doesn't register tools or run a loop, so magpie
doesn't become an agent runtime.

Ported from Tsukikage7/magpie#1. Changes from the fork:
- The entry name is magpie.hooks / *.hooks.*. The fork's magpie.gateway /
  *.gateway.mjs is already the middleware's alias, so a hook importing
  node:fs was also loaded as moejs middleware and failed there.
  TestGatewayHookNamesApartFromMiddleware fails if the two sets overlap.
- onRequest is rolled back, and counts as failed with no onResponse, when
  it throws, times out, returns non-JSON, or changes tools, tool_choice,
  function_call, functions, toolConfig, model or stream.
- onResponse gets the client-facing reply, merged through the gateway's own
  stream decoder, collector and renderer (no second merger).
- Codex's native passthrough (/backend-api/codex) runs the hooks too,
  without the sync middleware.
- The run ends with the request handler, not the client connection. Codex
  hangs up on response.completed, and the reply it got is still captured
  as a success. TestGatewayHookSeesReplyAfterClientHangsUp is red on the
  old `r.Context().Err()` check and green with -count=3.
- ctx.origin is host-derived (local / gateway-key / remote). Headers, keys
  and peer addresses never reach the hook.
- Plugins page: a hook package shows a "Request hook" chip, a diagnostics
  line (outcome code, calls, avg ms, bytes, failures; no content), and
  Options. Strings are in en, zh, zh-TW, ja and de.

Docs: docs/subsystems/gateway-request-hooks.md (new), provider-plugins.md,
gateway-middleware.md, and site docs plugins.html in en, zh and ja.

Real use, sandbox HOME on 127.0.0.1:3486 with the owner's real Codex Pro
sign-in. The probe hook adds a codename note and logs both callbacks:
- /v1/responses, /v1/messages, Gemini generateContent: stream and
  non-stream. onRequest's note reached the model (the answer had the
  codename), and onResponse got success=true and the whole reply.
- /v1/chat/completions: with the probe also changing `model`, the change
  was rolled back (the reply came from the asked model) and no onResponse
  ran. Without that change, earlier: stream and non-stream success.
- The real Codex CLI 0.162.1 `codex exec` through openai_base_url ->
  /backend-api/codex: the hook saw origin=local, agent=codex and the
  query; the answer had the codename; onResponse success=true (before the
  hang-up fix it never ran: the context was already cancelled).
- `magpie plugin list` shows only "async gateway hook onRequest" for the
  hook package, no failed middleware.

Tests (base origin/main 63be47717, macbook at load avg 220-340 from other
sessions' suites):
- gofmt -l: clean. go vet ./..., GOOS=linux go vet -tags nogui ./...,
  GOOS=windows go vet ./...: clean. go build and GOOS=linux -tags nogui
  build: ok.
- go test ./... -timeout 45m: every package ok except:
  - agent, gateway and library timed out at 45m under the load;
  - gui's TestSetAnswersWhileDevinAndProvidersHang (#1375, also red on a
    clean 63be47717 run alone; commented there);
  - library's TestSkillRelinkKeepsUnreadableCopy, which passes -count=2 alone.
  Rerun at -timeout 150m: agent ok (4524s), library ok (2581s). gateway was
  ok except TestVisionWaitIsntTheDescribersTime's 300ms limit (#2444,
  commented), which passes -count=5 alone on this tree and on 63be47717.
- internal/plugin and internal/gateway hook tests: ok.
- GUI (chromium+webkit; en, zh, zh-TW, ja, de): plugin-gateway 12/12 twice.
  It failed earlier at load ~340, chromium only, on page.goto's 5s (#2542).
  All 43 plugin-*.test.cjs files and mobile-web are green except:
  - plugin-move: red on a clean 63be47717 too (#2399, commented);
  - plugin-moved-signin: one 5s waitFor under load, then 6/6 twice.

Rebased onto ea3dee96a (21 commits; main touched host.go, host.js, i18n.js and
the plugin docs; clean rebase), then rerun at the rebased head:
- gofmt, vet (darwin, linux nogui, windows) and build: clean.
- go test: plugin ok, cli ok, gateway -run 'Hook|Middleware|Codex|Plugin' ok.
  gui ok except TestMainWindowCorners, which was killed under load (#1936)
  and passes alone.
- GUI: plugin-gateway 12/12, plugin-middleware 24/24, plugin-tools 22/22,
  plugin-agent 22/22.
- Real account with the rebased binary: every protocol and the real Codex
  CLI gave the same results as above (codename answered, success=true,
  chat's model change rolled back).

Co-authored-by: Tsukikage7 <65526564+Tsukikage7@users.noreply.github.com>
2026-10-16 20:48:51 +08:00

437 lines
17 KiB
Go

package gateway
import (
"context"
"encoding/json"
"io"
"net/http"
"net/http/httptest"
"os"
"path/filepath"
"strings"
"testing"
"time"
"github.com/yetone/magpie/internal/access"
"github.com/yetone/magpie/internal/catalog"
"github.com/yetone/magpie/internal/plugin"
"github.com/yetone/magpie/internal/provider"
"github.com/yetone/magpie/internal/testenv"
)
func TestAsyncGatewayResponseDoesNotHoldStream(t *testing.T) {
t.Setenv("MAGPIE_BUN", testenv.Bun(t))
t.Setenv("XDG_CONFIG_HOME", t.TempDir())
t.Setenv("XDG_CACHE_HOME", t.TempDir())
t.Cleanup(plugin.Settle)
generated := make(chan struct{})
first := make(chan string, 1)
completed := make(chan map[string]any, 1)
release := make(chan struct{})
notified := make(chan struct{}, 1)
observer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
var payload map[string]any
json.NewDecoder(r.Body).Decode(&payload)
completed <- payload
select {
case <-release:
case <-r.Context().Done():
}
w.WriteHeader(http.StatusNoContent)
}))
defer func() { close(release); observer.Close() }()
upstream := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "text/event-stream")
io.WriteString(w, sse(`data: {"id":"c1","model":"m1","choices":[{"index":0,"delta":{"content":"live answer"}}]}`))
w.(http.Flusher).Flush()
select {
case <-generated:
case <-r.Context().Done():
return
}
io.WriteString(w, sse(`data: {"id":"c1","model":"m1","choices":[{"index":0,"delta":{},"finish_reason":"stop"}]}`, "data: [DONE]"))
}))
defer upstream.Close()
if err := provider.Save(provider.Provider{ID: "fake", Name: "Fake", Key: "synthetic", Models: []string{"m1"}, Chat: upstream.URL + "/v1"}); err != nil {
t.Fatal(err)
}
abs := filepath.Join(t.TempDir(), "observer.hooks.js")
script := `export async function onRequest(body,ctx){ctx.state.question=ctx.query;return body}
export async function onResponse(body,ctx){await fetch(ctx.options.url,{method:"POST",body:JSON.stringify({body,success:ctx.success,question:ctx.state.question}),signal:ctx.signal})}`
if err := os.WriteFile(abs, []byte(script), 0o644); err != nil {
t.Fatal(err)
}
if _, err := plugin.Add(t.Context(), abs); err != nil {
t.Fatal(err)
}
if err := plugin.SetOptions(abs, map[string]any{"url": observer.URL, "gatewayTimeoutMs": 5000}); err != nil {
t.Fatal(err)
}
gw := httptest.NewServer(lanGuard(New().Handler()))
defer func() {
close(generated)
gw.CloseClientConnections()
gw.Close()
}()
// Client reads the first delta while upstream generation is still blocked.
go func() {
req, _ := http.NewRequestWithContext(t.Context(), "POST", gw.URL+"/v1/chat/completions", strings.NewReader(`{"model":"fake/m1","stream":true,"messages":[{"role":"user","content":"question"}]}`))
req.Header.Set("Authorization", "Bearer magpie")
res, err := gw.Client().Do(req)
if err != nil {
first <- err.Error()
notified <- struct{}{}
return
}
defer res.Body.Close()
buf := make([]byte, 1024)
n, _ := res.Body.Read(buf)
first <- string(buf[:n])
io.Copy(io.Discard, res.Body)
notified <- struct{}{}
}()
select {
case text := <-first:
if !strings.Contains(text, "live answer") {
t.Fatalf("first delta: %s", text)
}
case <-time.After(10 * time.Second):
t.Fatal("stream waited for completed generation")
}
generated <- struct{}{}
select {
case payload := <-completed:
if payload["success"] != true || payload["question"] != "question" || !strings.Contains(string(raw(payload["body"])), "live answer") {
t.Fatalf("completion: %+v", payload)
}
case <-time.After(10 * time.Second):
t.Fatal("missing completion notification")
}
select {
case <-notified:
case <-time.After(2 * time.Second):
t.Fatal("slow completion hook delayed client EOF")
}
}
// Exercise the asynchronous host and server guard with all agent wire APIs.
// Service-specific contracts belong to companion plugin integration tests.
func TestAsyncGatewayThroughProtocols(t *testing.T) {
t.Setenv("MAGPIE_BUN", testenv.Bun(t))
t.Setenv("XDG_CONFIG_HOME", t.TempDir())
t.Setenv("XDG_CACHE_HOME", t.TempDir())
t.Cleanup(plugin.Settle)
upstream := make(chan []byte, 20)
up := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
b, _ := io.ReadAll(r.Body)
upstream <- b
w.Header().Set("Content-Type", "text/event-stream")
io.WriteString(w, sse(`data: {"id":"c1","model":"m1","choices":[{"index":0,"delta":{"content":"recalled answer"}}]}`, `data: {"id":"c1","model":"m1","choices":[{"index":0,"delta":{},"finish_reason":"stop"}],"usage":{"prompt_tokens":3,"completion_tokens":2}}`, "data: [DONE]"))
}))
defer up.Close()
if err := provider.Save(provider.Provider{ID: "fake", Name: "Fake", Key: "upstream-secret", Models: []string{"m1"}, Chat: up.URL + "/v1"}); err != nil {
t.Fatal(err)
}
queries := make(chan map[string]any, 20)
contextService := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if r.Header.Get("Authorization") != "Bearer context-test" {
t.Error("context service authorization missing")
}
var payload map[string]any
json.NewDecoder(r.Body).Decode(&payload)
queries <- payload
w.Header().Set("Content-Type", "application/json")
var content any = "Recalled Quartz codename: QUARTZ-8413 (" + payload["session"].(string) + ")"
switch payload["query"] {
case "empty":
content = ""
case "invalid":
content = 123
case "denied":
w.WriteHeader(http.StatusForbidden)
return
}
json.NewEncoder(w).Encode(map[string]any{"context": content})
}))
defer contextService.Close()
abs := filepath.Join(t.TempDir(), "recall.hooks.js")
if err := os.WriteFile(abs, []byte(`
export async function onRequest(body,ctx) {
const response=await fetch(ctx.options.serverUrl,{method:"POST",headers:{"Authorization":ctx.options.authorization},body:JSON.stringify({session:ctx.session,query:ctx.query,origin:ctx.origin}),signal:ctx.signal})
if(!response.ok)throw new Error("unavailable")
const result=await response.json()
if(typeof result.context!=="string")throw new Error("invalid")
if(!result.context)return
const text="\n<external-context>"+result.context+"</external-context>"
const messages=ctx.protocol==="gemini"?body.contents:ctx.protocol==="responses"?body.input:body.messages
const m=messages.findLast(m=>m.role==="user")
if(typeof m.content==="string")m.content+=text
else if(ctx.protocol==="gemini")m.parts.push({text})
else m.content.push({type:ctx.protocol==="responses"?"input_text":"text",text})
return body
}`), 0o644); err != nil {
t.Fatal(err)
}
if _, err := plugin.Add(t.Context(), abs); err != nil {
t.Fatal(err)
}
if err := plugin.SetOptions(abs, map[string]any{"serverUrl": contextService.URL, "authorization": "Bearer context-test"}); err != nil {
t.Fatal(err)
}
gw := httptest.NewServer(lanGuard(New().Handler()))
defer gw.Close()
send := func(path, body, session string) []byte {
t.Helper()
req, err := http.NewRequestWithContext(t.Context(), "POST", gw.URL+path, strings.NewReader(body))
if err != nil {
t.Fatal(err)
}
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Authorization", "Bearer magpie-codex")
req.Header.Set(SessionHeader, session)
res, err := gw.Client().Do(req)
if err != nil {
t.Fatal(err)
}
defer res.Body.Close()
reply, _ := io.ReadAll(res.Body)
if res.StatusCode != 200 || !strings.Contains(string(reply), "recalled answer") {
t.Fatalf("agent reply: %d %s", res.StatusCode, reply)
}
return <-upstream
}
cases := []struct{ name, path, body string }{
{"chat", "/v1/chat/completions", `{"model":"fake/m1","stream":true,"messages":[{"role":"system","content":"<cwd>/tmp/quartz</cwd>"},{"role":"user","content":"Quartz codename?"}]}`},
{"responses", "/v1/responses", `{"model":"fake/m1","stream":true,"instructions":"<cwd>/tmp/quartz</cwd>","input":[{"role":"user","content":[{"type":"input_text","text":"Quartz codename?"}]}]}`},
{"codex-context", "/v1/responses", `{"model":"fake/m1","stream":true,"input":[{"role":"user","content":[{"type":"input_text","text":"<environment_context><cwd>/tmp/quartz</cwd></environment_context>"},{"type":"input_text","text":"Quartz codename?"}]}]}`},
{"anthropic", "/v1/messages", `{"model":"fake/m1","stream":true,"max_tokens":40,"system":"<cwd>/tmp/quartz</cwd>","messages":[{"role":"user","content":[{"type":"text","text":"Quartz codename?"}]}]}`},
{"gemini", "/v1beta/models/fake/m1:streamGenerateContent", `{"systemInstruction":{"parts":[{"text":"<cwd>/tmp/quartz</cwd>"}]},"contents":[{"role":"user","parts":[{"text":"Quartz codename?"}]}]}`},
}
for _, c := range cases {
t.Run(c.name, func(t *testing.T) {
got := string(send(c.path, c.body, "session-a"))
if strings.Count(got, "QUARTZ-8413") != 1 || !strings.Contains(got, "session-a") || !strings.Contains(got, "Quartz codename?") {
t.Fatalf("recall did not reach provider exactly once: %s", got)
}
if strings.Contains(got, "context-test") || strings.Contains(got, "magpie-codex") {
t.Fatalf("plugin credentials leaked upstream: %s", got)
}
query := <-queries
if query["query"] != "Quartz codename?" || query["session"] != "session-a" || query["origin"] != "local" {
t.Fatalf("wrong preparation: %+v", query)
}
})
}
if t.Failed() {
return
}
got := string(send(cases[0].path, cases[0].body, "session-b"))
<-queries
if !strings.Contains(got, "session-b") || strings.Contains(got, "session-a") {
t.Fatalf("session context leaked: %s", got)
}
for _, query := range []string{"empty", "invalid", "denied"} {
body := `{"model":"fake/m1","stream":true,"messages":[{"role":"user","content":"` + query + `"}]}`
got := string(send(cases[0].path, body, "session-a"))
<-queries
if strings.Contains(got, "external-context") || !strings.Contains(got, query) {
t.Fatalf("failed/empty recall changed prompt: %s", got)
}
}
if err := plugin.SetOff(abs, true); err != nil {
t.Fatal(err)
}
got = string(send(cases[0].path, cases[0].body, "session-a"))
if strings.Contains(got, "external-context") {
t.Fatalf("disabled plugin injected context: %s", got)
}
select {
case q := <-queries:
t.Fatalf("disabled plugin queried context service: %+v", q)
default:
}
}
func TestGatewayQueryUsesUserWords(t *testing.T) {
for _, tc := range []struct {
name string
messages []Message
want string
}{
{"Codex environment", []Message{userMsg(envContext, "Quartz codename?")}, "Quartz codename?"},
{"agent notices", []Message{userMsg("Quartz codename?"), userMsg(pluginRef, taskNotification)}, "Quartz codename?"},
{"tool-only increment", []Message{{Role: "user", Parts: []Part{{Kind: ToolResult, Text: "QUARTZ-8413"}}}}, ""},
{"context only", []Message{userMsg(envContext)}, ""},
} {
t.Run(tc.name, func(t *testing.T) {
if got := gatewayQuery(&Request{Messages: tc.messages}); got != tc.want {
t.Fatalf("query %q, want %q", got, tc.want)
}
})
}
}
// Exercise provenance through authentication and the real Bun lifecycle; a
// client's body/header claims cannot replace the host's classification.
func TestAsyncGatewayOrigin(t *testing.T) {
t.Setenv("MAGPIE_BUN", testenv.Bun(t))
t.Setenv("XDG_CONFIG_HOME", t.TempDir())
t.Setenv("XDG_CACHE_HOME", t.TempDir())
t.Cleanup(plugin.Settle)
if err := os.MkdirAll(filepath.Dir(catalog.CachePath()), 0o755); err != nil {
t.Fatal(err)
}
if err := os.WriteFile(catalog.CachePath(), []byte("{}"), 0o600); err != nil {
t.Fatal(err)
}
key, err := access.Update("add-key", access.Change{Name: "Shared"})
if err != nil {
t.Fatal(err)
}
abs := filepath.Join(t.TempDir(), "origin.hooks.mjs")
script := `export function onRequest(body,ctx){ctx.state.origin=ctx.origin;body.origin=ctx.origin;return body}
export async function onResponse(reply,ctx){await fetch(ctx.options.url,{method:"POST",body:JSON.stringify({origin:ctx.origin,before:ctx.state.origin}),signal:ctx.signal})}`
observed := make(chan map[string]string, 20)
observer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
var got map[string]string
json.NewDecoder(r.Body).Decode(&got)
observed <- got
w.WriteHeader(204)
}))
defer observer.Close()
if err := os.WriteFile(abs, []byte(script), 0o644); err != nil {
t.Fatal(err)
}
if _, err := plugin.Add(t.Context(), abs); err != nil {
t.Fatal(err)
}
if err := plugin.SetOptions(abs, map[string]any{"url": observer.URL}); err != nil {
t.Fatal(err)
}
for _, tc := range []struct{ name, peer, header, key, trust, want string }{
{"local", "127.0.0.1:1234", "", "", "0", "local"},
{"ipv6", "[::1]:1234", "", "", "0", "local"},
{"named-loopback", "127.0.0.1:1234", "", key, "0", "gateway-key"},
{"remote", "10.0.0.1:1234", "", key, "0", "gateway-key"},
{"proxy", "127.0.0.1:1234", "X-Forwarded-For", key, "0", "gateway-key"},
{"trusted-proxy", "127.0.0.1:1234", "Forwarded", "", "1", "remote"},
{"trusted-tunnel", "127.0.0.1:1234", "Tailscale-User-Login", "", "1", "remote"},
{"unknown-peer", "malformed", "", "", "0", "remote"},
} {
t.Run(tc.name, func(t *testing.T) {
t.Setenv("MAGPIE_TRUST_PROXY", tc.trust)
// The guard requires sharing for nonlocal peers, without opening a listener.
t.Setenv("MAGPIE_ADDR", "0.0.0.0:3425")
req := httptest.NewRequest("POST", "http://127.0.0.1/v1/chat/completions", strings.NewReader(`{"model":"fake/m1","origin":"local","messages":[{"role":"user","content":"hello"}]}`))
req.RemoteAddr = tc.peer
req.Header.Set("X-Magpie-Origin", "local")
if tc.header != "" {
req.Header.Set(tc.header, "remote-client")
}
if tc.key != "" {
req.Header.Set("Authorization", "Bearer "+tc.key)
}
// An invalid peer cannot pass the guard. Check it directly as a defensive
// classifier case; all accepted cases go through the complete lifecycle.
if tc.name == "unknown-peer" {
if got := gatewayOrigin(req); got != tc.want {
t.Fatalf("origin=%q, want %q", got, tc.want)
}
return
}
w := httptest.NewRecorder()
lanGuard(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w, b, done := gatewayHooks(w, r, provider.Chat, []byte(`{"model":"fake/m1","origin":"local","messages":[{"role":"user","content":"hello"}]}`))
defer done()
var got map[string]any
json.Unmarshal(b, &got)
if got["origin"] != tc.want {
t.Errorf("request origin=%v, want %s", got["origin"], tc.want)
}
w.Header().Set("Content-Type", "application/json")
io.WriteString(w, `{"choices":[{"message":{"role":"assistant","content":"ok"},"finish_reason":"stop"}]}`)
})).ServeHTTP(w, req)
if w.Code != 200 {
t.Fatalf("guard status=%d: %s", w.Code, w.Body.String())
}
select {
case got := <-observed:
if got["origin"] != tc.want || got["before"] != tc.want {
t.Fatalf("callback provenance=%v, want %s", got, tc.want)
}
case <-time.After(10 * time.Second):
t.Fatal("missing completion origin")
}
})
}
}
// Codex hangs up as soon as it reads response.completed, while ChatGPT may
// hold the connection a moment longer. The reply was delivered whole, so
// onResponse still sees it, as a success: the run ends with the handler,
// not with the client's connection.
func TestGatewayHookSeesReplyAfterClientHangsUp(t *testing.T) {
setup(t, provider.Chat, &fake{t: t})
held := make(chan struct{})
chatgpt(t, func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "text/event-stream")
io.WriteString(w, sse(`data: {"type":"response.output_text.delta","delta":"pong"}`,
`data: {"type":"response.completed","response":{"id":"r1","status":"completed","output":[{"type":"message","role":"assistant","content":[{"type":"output_text","text":"pong"}]}]}}`))
w.(http.Flusher).Flush()
select {
case <-held:
case <-r.Context().Done():
}
})
defer close(held)
t.Setenv("MAGPIE_BUN", testenv.Bun(t))
t.Cleanup(plugin.Settle)
completed := make(chan map[string]any, 1)
observer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
var payload map[string]any
json.NewDecoder(r.Body).Decode(&payload)
completed <- payload
}))
defer observer.Close()
abs := filepath.Join(t.TempDir(), "capture.hooks.js")
if err := os.WriteFile(abs, []byte(`export async function onRequest(body){return body}
export async function onResponse(reply,ctx){await fetch(ctx.options.url,{method:"POST",body:JSON.stringify({reply,success:ctx.success}),signal:ctx.signal})}`), 0o644); err != nil {
t.Fatal(err)
}
if _, err := plugin.Add(t.Context(), abs); err != nil {
t.Fatal(err)
}
if err := plugin.SetOptions(abs, map[string]any{"url": observer.URL, "gatewayTimeoutMs": 5000}); err != nil {
t.Fatal(err)
}
gw := httptest.NewServer(New().Handler())
defer gw.Close()
ctx, hangUp := context.WithCancel(t.Context())
defer hangUp()
req, _ := http.NewRequestWithContext(ctx, "POST", gw.URL+CodexPath+"/responses", strings.NewReader(`{"model":"gpt-5.5","stream":true,"input":"ping"}`))
req.Header.Set("Authorization", "Bearer chatgpt-token")
res, err := gw.Client().Do(req)
if err != nil {
t.Fatal(err)
}
read := ""
buf := make([]byte, 4096)
for !strings.Contains(read, "response.completed") {
n, err := res.Body.Read(buf)
read += string(buf[:n])
if err != nil {
t.Fatalf("stream ended before response.completed: %v %q", err, read)
}
}
hangUp() // as Codex does
res.Body.Close()
select {
case payload := <-completed:
if payload["success"] != true || !strings.Contains(string(raw(payload["reply"])), "pong") {
t.Fatalf("completion after hang-up: %+v", payload)
}
case <-time.After(10 * time.Second):
t.Fatal("onResponse never ran after the client hung up on a whole reply")
}
}