diff --git a/ext/js/background/backend.js b/ext/js/background/backend.js index 6de7092659..3f3c606301 100644 --- a/ext/js/background/backend.js +++ b/ext/js/background/backend.js @@ -2257,11 +2257,15 @@ export class Backend { if (!(typeof details === 'object' && details !== null)) { continue; } const error3 = /** @type {import('core').SerializableObject} */ (details).error; if (typeof error3 !== 'string') { continue; } - switch (/** @type {import('backend').NetError} */ (error3)) { + switch (error3) { 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': - case 'Peer’s Certificate has expired.': + 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); } } diff --git a/types/ext/backend.d.ts b/types/ext/backend.d.ts index 8f8b24b37e..13f3bfe490 100644 --- a/types/ext/backend.d.ts +++ b/types/ext/backend.d.ts @@ -31,12 +31,3 @@ export type TabInfo = { }; export type FindTabsPredicate = (tabInfo: TabInfo) => boolean | Promise; - -/** - * An enum representing the fetch error thrown by Chrome or Firefox. - * - `net::ERR_FAILED` - Chrome error. 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.``` - * - `net::ERR_CERT_DATE_INVALID` - Chrome error. - * - `Peer’s Certificate has expired.` - Firefox error. This error occurs when a server certificate expires. - */ -export type NetError = 'net::ERR_FAILED' | 'net::ERR_CERT_DATE_INVALID' | 'Peer’s Certificate has expired.';