From 27853412a37ca71ac2810fecf06da0f51c3ff95f Mon Sep 17 00:00:00 2001 From: Samuel Degueldre Date: Wed, 29 Sep 2021 10:46:18 +0000 Subject: [PATCH] [FIX] web: avoid masking crashes when original error has no stack MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In some contexts, an error caught by the error service has no stack, trying to annotate the stacktrace of this error with the Stacktrace library crashes, masking the original error which is unwanted. closes odoo/odoo#77421 X-original-commit: 347ddcc06e23d8f1a94c06379b2bfe104b116d90 Signed-off-by: Sébastien Theys (seb) --- addons/web/static/src/core/errors/error_utils.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/addons/web/static/src/core/errors/error_utils.js b/addons/web/static/src/core/errors/error_utils.js index 491c90e4ea9..e1c49025259 100644 --- a/addons/web/static/src/core/errors/error_utils.js +++ b/addons/web/static/src/core/errors/error_utils.js @@ -64,7 +64,14 @@ export async function annotateTraceback(error) { error.stack = error.stack.replace(regex, subst); } // eslint-disable-next-line no-undef - const frames = await StackTrace.fromError(error); + let frames; + try { + frames = await StackTrace.fromError(error); + } catch (e) { + // This can crash if the originalError has no stack/stacktrace property + console.warn("The following error could not be annotated:", error, e); + return traceback; + } const lines = traceback.split("\n"); if (lines[lines.length - 1].trim() === "") { // firefox traceback have an empty line at the end