From e79093437bda0b9b135cb402753c0f4f541105a4 Mon Sep 17 00:00:00 2001 From: Joel Einbinder Date: Mon, 4 Mar 2019 17:32:54 -0800 Subject: [PATCH] fix: check if async error has a stack (#4017) --- experimental/puppeteer-firefox/lib/helper.js | 2 +- lib/helper.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/experimental/puppeteer-firefox/lib/helper.js b/experimental/puppeteer-firefox/lib/helper.js index 30d1b867be5bd..81dd61d6808c8 100644 --- a/experimental/puppeteer-firefox/lib/helper.js +++ b/experimental/puppeteer-firefox/lib/helper.js @@ -32,7 +32,7 @@ class Helper { return method.call(this, ...args).catch(e => { const stack = syncStack.stack.substring(syncStack.stack.indexOf('\n') + 1); const clientStack = stack.substring(stack.indexOf('\n')); - if (!e.stack.includes(clientStack)) + if (e instanceof Error && e.stack && !e.stack.includes(clientStack)) e.stack += '\n -- ASYNC --\n' + stack; throw e; }); diff --git a/lib/helper.js b/lib/helper.js index ee1055c70a4a0..f434707c4fae2 100644 --- a/lib/helper.js +++ b/lib/helper.js @@ -109,7 +109,7 @@ class Helper { return method.call(this, ...args).catch(e => { const stack = syncStack.stack.substring(syncStack.stack.indexOf('\n') + 1); const clientStack = stack.substring(stack.indexOf('\n')); - if (!e.stack.includes(clientStack)) + if (e instanceof Error && e.stack && !e.stack.includes(clientStack)) e.stack += '\n -- ASYNC --\n' + stack; throw e; });