Commit bd6da95
test(proxy): fix data race and flaky deadline test in v2 CI
Two pre-existing issues in middleware/proxy made v2 CI red under
`go test -race` on newer Go versions and Windows:
1. Data race: Test_Proxy_Forward_WithTlsConfig called WithTlsConfig(),
which mutates the field client.TLSConfig on the package-global client
with no synchronization against fasthttp's concurrent read of that
field from parallel proxy tests. Swap the whole global client via
WithClient(&fasthttp.Client{TLSConfig: ...}) instead (pointer swap
under the existing lock), mirroring the v3 fix. The public
WithTlsConfig API is left untouched.
2. Flaky timing: Test_Proxy_DoDeadline_PastDeadline used a 1s DoDeadline
deadline equal to app.Test's default 1000ms timeout, so two coincident
timers raced. Bump the deadline to 2s so app.Test's timeout fires
first deterministically (same approach as v3).
Test-only change, no production or API changes. Verified 12/12 green
with `-race -shuffle=on`.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent 493b955 commit bd6da95
1 file changed
Lines changed: 6 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
249 | 249 | | |
250 | 250 | | |
251 | 251 | | |
252 | | - | |
253 | | - | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
254 | 255 | | |
255 | 256 | | |
256 | 257 | | |
| |||
565 | 566 | | |
566 | 567 | | |
567 | 568 | | |
568 | | - | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
569 | 572 | | |
570 | 573 | | |
571 | 574 | | |
| |||
0 commit comments