From abb3e5d5d0a63a20933f1770e03e87e756439d35 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Wed, 5 Oct 2022 22:51:15 -0400 Subject: Audio certificate error notification (#2243) * Refactor error throwing and change ID * Show a notification when an audio download fails due to an expired cert --- ext/issues.html | 17 ++++++++++++++++- ext/js/background/backend.js | 15 ++++++++++----- 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/ext/issues.html b/ext/issues.html index df6e6135..a436222e 100644 --- a/ext/issues.html +++ b/ext/issues.html @@ -25,7 +25,7 @@

Yomichan Issues

-

Audio download failed due to possible extension permissions error (Chrome)

+

Audio download failed due to possible extension permissions error (Chrome)

@@ -42,6 +42,21 @@

+

Audio download failed due to an expired server certificate

+
+
+

+ If a website failes to keep its HTTPS certificate up to date, + downloads can fail because the browser flags the connection as insecure. + This has happened occasionally for some websites that Yomichan interacts with, + and the issue is usually resolved within a day. +

+

+ This issue is a server-side issue that Yomichan doesn't have control over. +

+
+
+

Audio download was cancelled due to an idle timeout

diff --git a/ext/js/background/backend.js b/ext/js/background/backend.js index 20402539..197734b1 100644 --- a/ext/js/background/backend.js +++ b/ext/js/background/backend.js @@ -1936,11 +1936,16 @@ class Backend { if (!isObject(error2.data)) { continue; } const {details} = error2.data; if (!isObject(details)) { continue; } - if (details.error === 'net::ERR_FAILED') { - // This is potentially an error due to the extension not having enough URL privileges. - // The message logged to the console looks like this: - // Access to fetch at '' from origin 'chrome-extension://' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled. - return this._createAudioDownloadError('Audio download failed due to possible extension permissions error', 'audio-download-failed', errors); + switch (details.error) { + case 'net::ERR_FAILED': + // This is potentially an error due to the extension not having enough URL privileges. + // The message logged to the console looks like this: + // Access to fetch at '' from origin 'chrome-extension://' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled. + return this._createAudioDownloadError('Audio download failed due to possible extension permissions error', 'audio-download-failed-permissions-error', errors); + case 'net::ERR_CERT_DATE_INVALID': // Chrome + case 'Peer’s Certificate has expired.': // Firefox + // This error occurs when a server certificate expires. + return this._createAudioDownloadError('Audio download failed due to an expired server certificate', 'audio-download-failed-expired-server-certificate', errors); } } } -- cgit v1.2.3