A background summary calculation by HTTP request has appeared in the service. It must stop when the context is canceled, close the request body correctly, and not leave unfinished transactions. After a recent change, some requests started returning unexpected errors, and sometimes processing continues after cancellation. You need to find and fix the problems in the PR diff.
Environment: Go 1.24, standard library only. Synchronization between goroutines is allowed only via channels, sync.WaitGroup, and context.Context; there are no hidden dependencies.
API contract: HTTP POST /summaries accepts a stub body without external parameters and must return exactly one stdout log line in the form summary=ok status=201 if the operation completes successfully. This task checks code behavior, not running a real server.
You need to evaluate the proposed changes and list the real defects, each with an independent cause and reproduction.
Go 1.24, standard library only; execution mode: review of a small PR diff; assume deterministic single-process tests, no network access, no time-based assertions, and no extra files beyond those listed.
Use line comments to explain the problem, its impact, the fix and how to test it.