I have something like this:
t, err1 := template.ParseFiles("exampleFile.tmpl")
if err1 != nil {
panic(err1)
}
err2 := t.ExecuteTemplate(w, "example", someStruct)
if err2 != nil {
panic(err2)
}
With simple requests, there are no problems.
But if I send two requests very close to each other, about 40% of the time from simple page refreshes from Chrome and a few ajax requests, it results in various different errors (err2):
write tcp 127.0.0.1:8080->127.0.0.1:35212: write: broken pipe
write: connection reset by peer
use of closed network connection
http: panic serving 127.0.0.1:35814: runtime error: slice bounds out of range goroutine 340 (...)
Others seem to have had similar issues, but with no clear resolution.
- Filter out broken pipe errors from template execution
- https://groups.google.com/forum/#!topic/golang-nuts/g6UNu4Mrv28
Another post seems to suggest just to expect this, and retry failed requests:
What's the best Golang way to handle this?