charmbracelet / charmbracelet/bubbletea
docs: commands tutorial HTTP snippets omit response body cleanup
- Dominant language
- Go
- Stars
- 44.9k
- Forks
- 1.3k
- PR merge metrics
- No merged PRs in 30d
Description
### What happened?
Both HTTP snippets in `tutorials/commands/README.md` (`checkServer` and
`checkSomeUrl`) return the status without closing the response body after a
successful GET. The runnable `tutorials/commands/main.go` already defers
`res.Body.Close()`. Readers copying the README therefore miss the cleanup that
the corresponding source demonstrates.
Expected: close each successful response body before the command finishes.
Actual: a tracking body remains unclosed when either documented command returns.
This is a documentation/example ownership error, not a measured memory-leak claim.
### How can we reproduce this?
Copy either function from the README. In a small harness, replace
`http.DefaultTransport` with a RoundTripper returning a response with status 200
and this body, retaining a pointer to it:
```go
type trackingBody struct{ closed bool }
func (*trackingBody) Read([]byte) (int, error) { return 0, io.EOF }
func (b *trackingBody) Close() error { b.closed = true; return nil }
```
Call `checkServer()` or `checkSomeUrl("https://example.invalid/")()` and inspect
`closed` after return. Both produce status 200 and `closed == false`. Adding
`defer res.Body.Close()` after each successful error check makes it true.
Restore the original transport after the check; no network request is needed.
I verified both snippets with an in-memory transport and an AST comparison
against the README functions. The explicit-close control passed.
### Which version of bubbletea are you using?
Main commit `73b6d91ac1c3854dd4af046ab5f9e51d3b3b4290`.
### Which terminals did you reproduce this with?
Windows Go 1.26.3; a noninteractive HTTP-command harness, no terminal or live
server required.
### Search
- [x] I searched open/closed issues, PRs, discussions and file history.
The existing source-only cleanup in commit `22d15ef` does not update the two
README snippets. Discussion #562 concerns message types, not response cleanup.
Contributor guide
Research direction
Open tutorials/commands/README.md and locate the checkServer and checkSomeUrl snippets, then compare them with the cleanup already present in tutorials/commands/main.go. Ensure each successful GET closes its response body before the command returns, and verify both snippets with the in-memory transport or AST comparison described in the issue.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 1/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 92/100