diff --git a/experimental/puppeteer-firefox/lib/helper.js b/experimental/puppeteer-firefox/lib/helper.js index 81dd61d6..78dd01d6 100644 --- a/experimental/puppeteer-firefox/lib/helper.js +++ b/experimental/puppeteer-firefox/lib/helper.js @@ -28,7 +28,8 @@ class Helper { if (methodName === 'constructor' || typeof methodName !== 'string' || methodName.startsWith('_') || typeof method !== 'function' || method.constructor.name !== 'AsyncFunction') continue; Reflect.set(classType.prototype, methodName, function(...args) { - const syncStack = new Error(); + const syncStack = {}; + Error.captureStackTrace(syncStack); return method.call(this, ...args).catch(e => { const stack = syncStack.stack.substring(syncStack.stack.indexOf('\n') + 1); const clientStack = stack.substring(stack.indexOf('\n')); diff --git a/lib/helper.js b/lib/helper.js index 8fc0d16f..3c158133 100644 --- a/lib/helper.js +++ b/lib/helper.js @@ -107,7 +107,8 @@ class Helper { if (methodName === 'constructor' || typeof methodName !== 'string' || methodName.startsWith('_') || typeof method !== 'function' || method.constructor.name !== 'AsyncFunction') continue; Reflect.set(classType.prototype, methodName, function(...args) { - const syncStack = new Error(); + const syncStack = {}; + Error.captureStackTrace(syncStack); return method.call(this, ...args).catch(e => { const stack = syncStack.stack.substring(syncStack.stack.indexOf('\n') + 1); const clientStack = stack.substring(stack.indexOf('\n'));