From bc0b04beef3244280e6569a233173d512adaa9d8 Mon Sep 17 00:00:00 2001 From: jrandolf <101637635+jrandolf@users.noreply.github.com> Date: Tue, 6 Jun 2023 09:11:46 +0200 Subject: [PATCH] fix: ensure stack trace contains one line (#10317) --- packages/puppeteer-core/src/common/util.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/puppeteer-core/src/common/util.ts b/packages/puppeteer-core/src/common/util.ts index 71922281..fabc68d5 100644 --- a/packages/puppeteer-core/src/common/util.ts +++ b/packages/puppeteer-core/src/common/util.ts @@ -147,8 +147,11 @@ export function createClientError( const getErrorDetails = (details: Protocol.Runtime.ExceptionDetails) => { let name = ''; let message: string; - const lines = details.exception?.description?.split('\n') ?? []; - const size = details.stackTrace?.callFrames.length ?? 0; + const lines = details.exception?.description?.split('\n at ') ?? []; + const size = Math.min( + details.stackTrace?.callFrames.length ?? 0, + lines.length - 1 + ); lines.splice(-size, size); if (details.exception?.className) { name = details.exception.className;