From 98f570c103f95e74062cf1e406b843b869de38c8 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Thu, 7 Nov 2019 11:37:48 +0100 Subject: [PATCH] Prevent browser exceptions from incorrectly triggering the `assert` in `PDFPageProxy._abortOperatorList` (PR 11069 follow-up) For certain canvas-related errors (and probably others), the browser rendering exceptions may be propagated "as-is" to the PDF.js code. In this case, the exceptions are of the somewhat cryptic `NS_ERROR_FAILURE` type. Unfortunately these aren't actual `Error`s, which thus ends up unintentionally triggering the `assert` in `PDFPageProxy._abortOperatorList`; sorry about that! --- src/display/api.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/display/api.js b/src/display/api.js index eedac49db..3514d9efa 100644 --- a/src/display/api.js +++ b/src/display/api.js @@ -1378,7 +1378,8 @@ class PDFPageProxy { * @private */ _abortOperatorList({ intentState, reason, force = false, }) { - assert(reason instanceof Error, + assert(reason instanceof Error || + (typeof reason === 'object' && reason !== null), 'PDFPageProxy._abortOperatorList: Expected "reason" argument.'); if (!intentState.streamReader) {