Propagate request context in block REST handlers.
Some checks failed
Deploy Explorer Live / deploy (push) Failing after 24s
Some checks failed
Deploy Explorer Live / deploy (push) Failing after 24s
Use r.Context() for DB query timeouts so client disconnects cancel in-flight block lookups instead of running against a detached background context. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -21,7 +21,7 @@ func (s *Server) handleGetBlockByNumber(w http.ResponseWriter, r *http.Request,
|
||||
}
|
||||
|
||||
// Add query timeout
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
||||
ctx, cancel := context.WithTimeout(r.Context(), 5*time.Second)
|
||||
defer cancel()
|
||||
|
||||
query := `
|
||||
@@ -89,7 +89,7 @@ func (s *Server) handleGetBlockByHash(w http.ResponseWriter, r *http.Request, ha
|
||||
}
|
||||
|
||||
// Add query timeout
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
||||
ctx, cancel := context.WithTimeout(r.Context(), 5*time.Second)
|
||||
defer cancel()
|
||||
|
||||
query := `
|
||||
|
||||
Reference in New Issue
Block a user