From fbdb7c1f30743a73e2e5ea800f20f5e7d168a075 Mon Sep 17 00:00:00 2001 From: Abe Jellinek <1770299+AbeJellinek@users.noreply.github.com> Date: Fri, 22 May 2026 10:29:20 -0400 Subject: [PATCH] Read Aloud: Fix 402 handling --- chrome/content/zotero/xpcom/sync/syncAPIClient.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/chrome/content/zotero/xpcom/sync/syncAPIClient.js b/chrome/content/zotero/xpcom/sync/syncAPIClient.js index 8fe24229f2..b5bd4671ee 100644 --- a/chrome/content/zotero/xpcom/sync/syncAPIClient.js +++ b/chrome/content/zotero/xpcom/sync/syncAPIClient.js @@ -672,8 +672,8 @@ Zotero.Sync.APIClient.prototype = { let method; let url; let options = { - // Could be a blob (audio bytes) or an application/json envelope with `audioURL` - // and `timestamps`; we inspect the Content-Type before parsing. + // Could be audio bytes or a JSON { audioURL, timestamps } object + // Inspect the Content-Type before parsing responseType: "arraybuffer", errorDelayMax: 8000, }; @@ -715,7 +715,13 @@ Zotero.Sync.APIClient.prototype = { let error; if (e instanceof Zotero.HTTP.UnexpectedStatusException && e.status === 402) { - let body = await e.xmlhttp.response?.text(); + let body = null; + try { + body = new TextDecoder().decode(e.xmlhttp.response); + } + catch { + // Ignore + } error = body === 'daily_limit_exceeded' ? 'daily-limit-exceeded' : 'quota-exceeded'; } else if (e instanceof Zotero.HTTP.BrowserOfflineException) {