Skip to content

Fix state transfer rate before the bar starts - #240

Merged
schollz merged 1 commit into
schollz:mainfrom
jakezwang:fix/state-rate-before-start
Sep 19, 2026
Merged

schollz merged 1 commit into
schollz:mainfrom
jakezwang:fix/state-rate-before-start

Conversation

@jakezwang

Copy link
Copy Markdown
Contributor

Before the first update, New64(100).State() computes the transfer rate as 0/0, producing NaN. This makes the state impossible to encode as JSON, and the /state handler created by StartHTTPServer returns an empty body.

Leave the rate at zero until positive elapsed time is available. Add regressions for unstarted known-length, unknown-length, and resumed bars, their transition to a positive rate, and an actual initial /state request.

Validation: full go test -race -cover -vet=off . on Go 1.25.13 and 1.26.6; go vet .; go mod tidy -diff; go build ./.... The three initial-state cases and HTTP regression fail before the fix and pass afterward.

@schollz

schollz commented Sep 19, 2026

Copy link
Copy Markdown
Owner

Thanks!! Looks good

@schollz
schollz merged commit 7562c11 into schollz:main Sep 19, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants