mirror of
https://github.com/ikechan8370/chatgpt-plugin.git
synced 2025-12-16 21:37:11 +00:00
feat: 尝试加入重试机制降低Sydney不响应的概率
This commit is contained in:
parent
af6bd77f6b
commit
f0903eeee3
2 changed files with 46 additions and 31 deletions
|
|
@ -200,7 +200,8 @@ export default class SydneyAIClient {
|
|||
parentMessageId = invocationId || crypto.randomUUID(),
|
||||
onProgress,
|
||||
abortController = new AbortController(),
|
||||
timeout = Config.defaultTimeoutMs
|
||||
timeout = Config.defaultTimeoutMs,
|
||||
firstMessageTimeout = 10000
|
||||
} = opts
|
||||
if (typeof onProgress !== 'function') {
|
||||
onProgress = () => {}
|
||||
|
|
@ -341,10 +342,17 @@ export default class SydneyAIClient {
|
|||
reject(new Error('Timed out waiting for response. Try enabling debug mode to see more information.'))
|
||||
}
|
||||
}, timeout)
|
||||
const firstTimeout = setTimeout(() => {
|
||||
if (!replySoFar) {
|
||||
this.cleanupWebSocketConnection(ws)
|
||||
reject(new Error('Timed out waiting for first message.'))
|
||||
}
|
||||
}, firstMessageTimeout)
|
||||
|
||||
// abort the request if the abort controller is aborted
|
||||
abortController.signal.addEventListener('abort', () => {
|
||||
clearTimeout(messageTimeout)
|
||||
clearTimeout(firstTimeout)
|
||||
this.cleanupWebSocketConnection(ws)
|
||||
if (replySoFar) {
|
||||
resolve({
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue