Skip to content

Commit d05f189

Browse files
authored
Fix: RateLimit requests were not released when a streaming generation exception occurred (#11540)
1 parent ceaa9f1 commit d05f189

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

api/core/app/features/rate_limiting/rate_limit.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def __next__(self):
110110
raise StopIteration
111111
try:
112112
return next(self.generator)
113-
except StopIteration:
113+
except Exception:
114114
self.close()
115115
raise
116116

api/services/app_generate_service.py

+3
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,9 @@ def generate(
108108
raise ValueError(f"Invalid app mode {app_model.mode}")
109109
except RateLimitError as e:
110110
raise InvokeRateLimitError(str(e))
111+
except Exception:
112+
rate_limit.exit(request_id)
113+
raise
111114
finally:
112115
if not streaming:
113116
rate_limit.exit(request_id)

0 commit comments

Comments
 (0)