fix(transport): SSE Events reuses c.hc so a hung connect can't wedge the daemon 🔌
Events() used a bare &http.Client{} (zero timeouts) — a black-holed TCP connect
blocked the daemon's reconnect loop forever (backoff only fires on stream
error/close, not a stuck connect). The bare client existed to dodge round-1's
30s TOTAL timeout on c.hc; round 2 removed that, so c.hc now bounds dial/TLS
with NO total timeout — exactly right for a long-lived SSE stream — and is
proxy-aware. One-line swap.
This commit is contained in:
parent
55e1e77fc6
commit
d367e0ca8f
1 changed files with 7 additions and 4 deletions
|
|
@ -156,7 +156,10 @@ func (c *Client) PutBlob(hash string, data []byte) error {
|
||||||
|
|
||||||
// Events opens an SSE stream of hub change events (optionally filtered to one
|
// Events opens an SSE stream of hub change events (optionally filtered to one
|
||||||
// share) and calls onEvent for each, until ctx is cancelled or the stream ends.
|
// share) and calls onEvent for each, until ctx is cancelled or the stream ends.
|
||||||
// Uses a dedicated timeout-less client since the stream is long-lived.
|
// Reuses c.hc: it bounds dial/TLS (so a black-holed connect can't hang the
|
||||||
|
// reconnect loop forever) but has no TOTAL timeout, which is what a long-lived
|
||||||
|
// SSE stream needs — the hub sends headers on connect so ResponseHeaderTimeout
|
||||||
|
// never trips mid-stream. (A bare client here would also silently drop proxy env.)
|
||||||
func (c *Client) Events(ctx context.Context, share string, onEvent func(proto.Event)) error {
|
func (c *Client) Events(ctx context.Context, share string, onEvent func(proto.Event)) error {
|
||||||
u := c.base + proto.PathEvents
|
u := c.base + proto.PathEvents
|
||||||
if share != "" {
|
if share != "" {
|
||||||
|
|
@ -167,7 +170,7 @@ func (c *Client) Events(ctx context.Context, share string, onEvent func(proto.Ev
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
req.Header.Set(proto.AuthHeader, "Bearer "+c.bearer)
|
req.Header.Set(proto.AuthHeader, "Bearer "+c.bearer)
|
||||||
resp, err := (&http.Client{}).Do(req)
|
resp, err := c.hc.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue