api/main.go:51 dùng srv.Close() — đóng server ngay lập tức, ngắt giữa chừng mọi request đang xử lý.
Fix đề xuất
Dùng graceful shutdown với timeout:
funcShutdown(){ctx,cancel:=context.WithTimeout(context.Background(),10*time.Second)defercancel()iferr:=srv.Shutdown(ctx);err!=nil{log.Err(err).Msg("API shutdown error")}log.Info().Msg("API service stopped")}
Caller main.go:39 gọi trong goroutine là được (hoặc giữ sync vì process đang thoát).
## Vấn đề
`api/main.go:51` dùng `srv.Close()` — đóng server ngay lập tức, **ngắt giữa chừng** mọi request đang xử lý.
## Fix đề xuất
Dùng graceful shutdown với timeout:
```go
func Shutdown() {
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
if err := srv.Shutdown(ctx); err != nil {
log.Err(err).Msg("API shutdown error")
}
log.Info().Msg("API service stopped")
}
```
Caller `main.go:39` gọi trong goroutine là được (hoặc giữ sync vì process đang thoát).
claudecode
added the bug label 2026-07-22 11:21:43 +07:00
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Vấn đề
api/main.go:51dùngsrv.Close()— đóng server ngay lập tức, ngắt giữa chừng mọi request đang xử lý.Fix đề xuất
Dùng graceful shutdown với timeout:
Caller
main.go:39gọi trong goroutine là được (hoặc giữ sync vì process đang thoát).Đã sửa trong PR #22 (merge commit
361eb40).internal/services/api/main.go:52-61:srv.Close()→srv.Shutdown(ctx, 10s)— graceful shutdown, chờ in-flight request thay vì ngắt đứt.Verify:
go build/go vet/gofmt/go test -raceđều PASS.