Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
apiserver: forward panic in WithTimeout filter
- Loading branch information
Showing
3 changed files
with
36 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -91,14 +91,19 @@ func (t *timeoutHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { | |
return | ||
} | ||
|
||
done := make(chan struct{}) | ||
result := make(chan interface{}) | ||
tw := newTimeoutWriter(w) | ||
go func() { | ||
defer func() { | ||
result <- recover() | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
sttts
Author
Contributor
|
||
}() | ||
t.handler.ServeHTTP(tw, r) | ||
close(done) | ||
}() | ||
select { | ||
case <-done: | ||
case err := <-result: | ||
if err != nil { | ||
panic(err) | ||
} | ||
return | ||
case <-after: | ||
postTimeoutFn() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This change breaks the ability to get a useful stack trace when something panics.