Commit 4153460
fix: close HTTP response body and thread context in pricing API
The pricing API pagination loop had two issues:
1. res.Body was never closed, leaking an HTTP connection and its
file descriptor on every page fetch. Over dozens of pages during
each 12-hour pricing update, this accumulates leaked connections.
2. http.Get was used instead of http.NewRequestWithContext, meaning
the context parameter was ignored (_ context.Context). This
prevented cancellation during operator shutdown, potentially
blocking the goroutine indefinitely.
Fix: use http.NewRequestWithContext to propagate the context, and
explicitly close res.Body after reading (not defer, since we're
in a loop).
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>1 parent e51328d commit 4153460
1 file changed
+8
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
49 | | - | |
| 49 | + | |
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
| |||
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
69 | | - | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
70 | 74 | | |
71 | 75 | | |
72 | 76 | | |
73 | 77 | | |
74 | 78 | | |
| 79 | + | |
75 | 80 | | |
76 | 81 | | |
77 | 82 | | |
78 | 83 | | |
| 84 | + | |
79 | 85 | | |
80 | 86 | | |
81 | 87 | | |
| |||
0 commit comments