Skip to content

Commit 0452d89

Browse files
committed
Fixed an issue that API requests does not follow the specified timeout value
1 parent fb1a70b commit 0452d89

1 file changed

Lines changed: 2 additions & 6 deletions

File tree

Private/Invoke-OpenAIAPIRequestSSE.ps1

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -225,14 +225,10 @@ function Invoke-OpenAIAPIRequestSSE {
225225

226226
# Note:
227227
# In some situations, the server may unilaterally close the connection without sending any data.
228-
# To avoid long blocking waits that prevent user cancellation, we use a polling interval.
229-
# We allow a maximum total wait of 30 seconds while checking for cancellation every 500 ms.
230-
$timeoutMs = 30000
228+
# To avoid long blocking waits that prevent user cancellation, check for cancellation every 500 ms.
231229
$pollInterval = 500 # milliseconds
232-
$stopwatch = [System.Diagnostics.Stopwatch]::StartNew()
233-
234230
$readTask = $StreamReader.ReadLineAsync()
235-
while (-not $CancelToken.IsCancellationRequested -and $stopwatch.ElapsedMilliseconds -lt $timeoutMs) {
231+
while (-not $CancelToken.IsCancellationRequested) {
236232
if ($readTask.Wait($pollInterval, $CancelToken)) {
237233
break
238234
}

0 commit comments

Comments
 (0)