Repository navigation
Fix the dashboard speed test (upload leg never completed) and surface HTTP errors - #1
Merged
Merged
Conversation
… HTTP errors The RUN SPEED TEST button always failed on the upload leg. measureStream launched its worker goroutines but never joined them, so onDemandSpeed read the upload tally while it was still empty and reported 'upload: no data received'. The upload worker streams one 50MB POST per goroutine, which can't finish inside the ~4s reduced-load window, so it recorded no 200 before the premature read; download worked because it records a 200 on the first response -- which is why only the upload leg failed and the button never once succeeded. Fix: measureStream now wraps its workers in a sync.WaitGroup and waits after cancel (also closing a goroutine leak). A window-end cancellation is no longer counted as a transport error. New speedLegErr treats a leg that pushed real bytes with no server rejection as a success even with zero recorded 200s (fixes upload), while a server rejection still wins and is surfaced. Error visibility: tallyErr now distinguishes HTTP status failures -- 429 -> 'rate-limited by server (HTTP 429) — try again in a bit', 503 with Retry-After -> similar, other 5xx -> 'server error (HTTP N)', else 'server returned HTTP N' -- which flow into the panel error. The client JS already matched the wire shape, so no JS change was needed. SSRF protections are unchanged (validateSpeedTarget allowlist + dial-time guardedDialContext re-check verified intact). Tests: TestMeasureStreamJoinsWorkers (root-cause regression), TestSpeedLegErr, TestDefaultConfigSpeedTargetsValidate, extended TestValidateSpeedTarget and TestTallyErrClassification (429/503/502). Verified end to end: before download/upload 0 ok:false; after download 29.16 / upload 30.74 Mbps ok:true.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Root cause — the button never once succeeded
RUN SPEED TESTalways failed on the upload leg.measureStream(speed.go) launched its worker goroutines but never joined them — it computed samples, calledcancel(), and returned. The ok-aware upload worker streams one ~50 MB POST per goroutine, which can't finish inside the ~4 s reduced-load window, so it recorded no 200 / non-200 / transport error beforemeasureStreamreturned.onDemandSpeedthen read the empty upload tally ->ok:false, "upload: no data received". Download always worked (it records a 200 on the first response), which is exactly why only the upload leg failed.Before:
{download_mbps:0, upload_mbps:0, ok:false, error:"upload: no data received..."}After:
{download_mbps:29.16, upload_mbps:30.74, latency_ms:24.93, ok:true}Fix
measureStream: wrap workers in async.WaitGroupandwg.Wait()aftercancel()so a tally-recording worker has finished before the caller reads the tally (also closes a goroutine leak). The--speedCLI path is behavior-identical.ctx.Err() != nil) is no longer recorded as a transport error (it's normal termination). NewspeedLegErrtreats a leg that pushed real bytes with no server rejection as a success even with zero recorded 200s (fixes upload); a server rejection still wins and is surfaced.Error visibility (incl. the requested 429 handling)
tallyErrnow distinguishes HTTP status failures and flows them into the panel error:The client JS already matched the wire shape (
download_mbps/upload_mbps/latency_ms/jitter_ms/target/ok/error), so no JS change was needed — the contract was never the bug.SSRF protections — intact (verified live)
missing header -> 403, GET -> 405, custom->127.0.0.1 -> 400, custom->169.254.169.254 -> 400, non-loopback Origin -> 403.
validateSpeedTargetallowlist + dial-timeguardedDialContextre-check untouched — only accept-rows added, no block relaxed.Tests
TestMeasureStreamJoinsWorkers(root-cause regression),TestSpeedLegErr,TestDefaultConfigSpeedTargetsValidate, extendedTestValidateSpeedTarget(default Cloudflare targets accepted) andTestTallyErrClassification(429 / 503+Retry-After / bare 503 / 502).go build/vet/testgreen;-raceclean; dashboard guard tests pass.