Skip to content

Commit 78aac34

Browse files
committed
Request logger should be streaming-aware
1 parent f831bb5 commit 78aac34

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

server/middleware/request_logger.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,14 @@ def save_to_database(response, elapsed_time_seconds=None, response_preview=""):
286286

287287
# Get response info
288288
response_length = 0
289-
if hasattr(response, "data") and response.data:
289+
# Check if it's a streaming response first to avoid RuntimeError
290+
if hasattr(response, "direct_passthrough") and response.direct_passthrough:
291+
# Streaming response - can't access data directly
292+
response_length = 0
293+
elif hasattr(response, "is_streamed") and response.is_streamed:
294+
# SSE/streaming response - can't access data directly
295+
response_length = 0
296+
elif hasattr(response, "data") and response.data:
290297
response_length = len(response.data)
291298

292299
# Truncate response preview

0 commit comments

Comments
 (0)