From 192008bc724e8619163f71ecf1e3405b4d25b942 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wojciech=20Tyczy=C5=84ski?= Date: Wed, 20 Nov 2024 15:57:21 +0100 Subject: [PATCH] fix(PS5): Prevent uncaught promise rejections when requests are aborted (#7637) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On PS5 we are seeing following uncaught exceptions when requests are aborted: ``` [Error] Fetch is aborted – PromiseRejectionEvent {isTrusted: false, promise: Promise, reason: AbortError: Fetch is aborted, …} PromiseRejectionEvent {isTrusted: false, promise: Promise, reason: AbortError: Fetch is aborted, type: "unhandledrejection", target: Window, …}PromiseRejectionEvent (anonymous function) (Anonymous Script 1 (line 429)) [Error] Unhandled Promise Rejection: AbortError: Fetch is aborted promiseEmptyOnRejected promiseReactionJob ``` --- lib/util/abortable_operation.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/util/abortable_operation.js b/lib/util/abortable_operation.js index 37fe63d0b0..4013d509f5 100644 --- a/lib/util/abortable_operation.js +++ b/lib/util/abortable_operation.js @@ -166,6 +166,9 @@ shaka.util.AbortableOperation = class { */ chain(onSuccess, onError) { const newPromise = new shaka.util.PublicPromise(); + // Silence uncaught rejection errors, which may otherwise occur any place + // we don't explicitly handle aborted operations. + newPromise.catch(() => {}); const abortError = shaka.util.AbortableOperation.abortError(); // If called before "this" completes, just abort "this".