From 1ab59f4079636338c51cd8c2f5ebb1d3c3c951e2 Mon Sep 17 00:00:00 2001 From: kudo-sync-bot Date: Wed, 15 Jan 2025 13:41:13 -0800 Subject: [PATCH] =?UTF-8?q?Added=20manual=20timeout=20to=20`processStreamT?= =?UTF-8?q?ext()`=20to=20handle=20missing=20`done`=20signal=20from=20`read?= =?UTF-8?q?er.read()`=20in=20Chromium=20browsers=20=E2=86=9E=20[auto-sync?= =?UTF-8?q?=20from=20https://github.com/adamlui/ai-web-extensionss/tree/ma?= =?UTF-8?q?in/bravegpt]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- chatgpt/bravegpt/bravegpt.user.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/chatgpt/bravegpt/bravegpt.user.js b/chatgpt/bravegpt/bravegpt.user.js index 6656f2b82..ecef9d9e6 100644 --- a/chatgpt/bravegpt/bravegpt.user.js +++ b/chatgpt/bravegpt/bravegpt.user.js @@ -148,7 +148,7 @@ // @description:zu Yengeza izimpendulo ze-AI ku-Brave Search (inikwa amandla yi-GPT-4o!) // @author KudoAI // @namespace https://kudoai.com -// @version 2025.1.15.4 +// @version 2025.1.15.5 // @license MIT // @icon https://assets.bravegpt.com/images/icons/bravegpt/icon48.png?v=df624b0 // @icon64 https://assets.bravegpt.com/images/icons/bravegpt/icon64.png?v=df624b0 @@ -3405,9 +3405,14 @@ reader.read().then(processStreamText).catch(err => log.error('Error processing stream', err.message)) function processStreamText({ done, value }) { + + // Handle stream done if (done) { handleProcessCompletion() ; return } let chunk = new TextDecoder('utf8').decode(new Uint8Array(value)) if (chunk.includes(apis[caller.api].watermark)) { handleProcessCompletion() ; return } + this.timeout = setTimeout(handleProcessCompletion, 500) // since reader.read() doesn't signal done in Chromium + + // Process/show chunk if (caller.api == 'MixerBox AI') { // pre-process chunks const extractedChunks = Array.from(chunk.matchAll(/data:(.*)/g), match => match[1] .replace(/\[SPACE\]/g, ' ').replace(/\[NEWLINE\]/g, '\n')) @@ -3444,7 +3449,7 @@ } function handleProcessCompletion() { - caller.sender = null + caller.sender = this.timeout = null if (appDiv.querySelector('.loading')) // no text shown api.tryNew(caller) else { // text was shown