fix: isolate REST timeout middleware handler context (#49982)
Related to #49981 The REST timeout middleware could return a timeout response while the handler goroutine continued using the original Gin context. Once Gin recycled that context, late handler writes could race with a later request and trigger concurrent map writes. Run timeout-wrapped handlers with a copied Gin context and a fully buffered response recorder instead. The original context and real response writer now remain owned by the middleware goroutine, while normal completion explicitly propagates selected metadata and commits the recorder. Timeout closes the recorder and writes the 408 response through the real writer, so late handler writes are discarded safely. Add tests for recorder isolation, normal buffered commits, metadata and abort propagation, late writes after timeout, and race validation of the late-write timeout path. Signed-off-by: Congqi Xia <congqi.xia@zilliz.com>
C
congqixia committed
08b723a117ba973a38bf54e4de2eb4ffdffd1ace
Parent: 3851df6
Committed by GitHub <noreply@github.com>
on 5/22/2026, 8:00:31 AM