Skip to content

fix http server race

Christopher Schinnerl requested to merge fix-http-race into master

Created by: ChrisSchinnerl

This PR fixes the random race condition when we call WriteJSON. It seems like the std lib flushes the underlying buffer in FinishRequest, but before calling FinishRequest it cancels the context. This means, that r.Context().Done() will always trigger before done in our select and might cause a situation where FinishRequest is called at the same time as ServeHTTP. Both of those functions use the same buffer.

Merge request reports