← Back to Pull requests

Fail StreamController writes once the response is in #62

Closed
unknown closed this pull request without merging on Nov 30, 2026 16:42 UTC
View on GitHub
unknown unknown commented on Nov 24, 2026 23:56 UTC
Author

Summary

Fixes the StreamController panic Brad flagged during review of #61, which is now on main, and the hang that dnclient's log streaming actually hits. Both are in streamingPostDNClient's response goroutine.

  • Panic: the response goroutine could store two errors of different concrete types in the atomic.Value, e.g. a body read error and then the status error. A second store with a different type panics and takes dnclient down.

  • Hang: when the request ended, nothing closed the request pipe. If the server rejected a log stream mid-transfer, dnclient's next Write blocked forever. That leaked the goroutine, left Nebula at the verbose log level, and kept one StreamLogsMax slot in use.
  •  response goroutine
    -  several sc.err.Store(...) calls (atomic.Value)
    +  decide one error: Do failed > 401 > errors array > read error > bad status
    +  save it, close(done), then pr.CloseWithError(err)
     Write
    -  stores the pipe error too
    +  stores nothing; after the request ends it returns the request's error
    +  (io.ErrClosedPipe after a 200)
    

    A non-200 never ends up with a nil error. Write after a 200 also no longer hangs.

    Evidence

  • TestStreamControllerResponse: success, an errors array, no errors array, a truncated body, a complete body followed by a read failure, a 401, a truncated 401 and a truncated 200. On the old code these panic or report the wrong result.

  • TestStreamControllerEndUnblocksWrite: a Write provably in flight (one byte still unread) returns once the server rejects the request or the transport sees the context end. On the old code it hangs.

  • -race -count=50 passes.
  • Not fixed

    If the context is canceled on an idle stream, no Write is pending and the transport waits in the request body's Read. Do then doesn't return until the caller calls Close. This predates the change. dnclient always calls Close in a defer, so it isn't affected.

    Merge Danger

    Door: two-way

    Blast Radius: small

    Only the streaming path changes. Write after the request ends now returns an error instead of blocking.

    Diff: 262 lines (+196 / -66) across 3 files Reviewer: jasikpark Review duration: 8205m
    All Vouch review confidence checks passed
    Residual risk 0.17 = Change Risk (0.39) × (1 − Review Confidence (0.57)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.39 · 262 lines diff across 3 files
    0.39
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    56%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.333
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #62"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 56.8% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 39.3% (MEDIUM) · Higher = larger blast radius
    39.3%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 56.8% · Lower = rushed or shallow review
    56.8%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 17.0% · Safe to merge
    17.0%