From c09f0b7c501e053f61cc58ef7cb265c0dd7a3bd7 Mon Sep 17 00:00:00 2001 From: matthew-blackman Date: Tue, 14 May 2024 12:57:32 -0400 Subject: [PATCH 1/2] Increase stack trace limit for Errors created by assert - see https://github.com/phetsims/assert/issues/9 --- js/assert.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/js/assert.js b/js/assert.js index bbef4d2..dcac663 100644 --- a/js/assert.js +++ b/js/assert.js @@ -25,6 +25,17 @@ if ( window.QueryStringMachine && QueryStringMachine.containsKey( 'debugger' ) ) { debugger; // eslint-disable-line no-debugger } + + // Check if Error.stackTraceLimit exists and is writable + const descriptor = Object.getOwnPropertyDescriptor( Error, 'stackTraceLimit' ); + const stackTraceWritable = descriptor && ( descriptor.writable || ( descriptor.set && typeof descriptor.set === 'function' ) ); + + if ( stackTraceWritable ) { + + // @ts-ignore + Error.stackTraceLimit = 100; + } + throw new Error( assertPrefix + messages.join( '\n ' ) ); } }; From 27cf5d50431ff20ddf8707543e88e5696c8810bc Mon Sep 17 00:00:00 2001 From: Michael Kauzmann Date: Tue, 14 May 2024 12:16:52 -0600 Subject: [PATCH 2/2] smaller limit for all cases, https://github.com/phetsims/assert/issues/9 Signed-off-by: Michael Kauzmann --- js/assert.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/assert.js b/js/assert.js index dcac663..c4cdfb6 100644 --- a/js/assert.js +++ b/js/assert.js @@ -33,7 +33,7 @@ if ( stackTraceWritable ) { // @ts-ignore - Error.stackTraceLimit = 100; + Error.stackTraceLimit = 20; } throw new Error( assertPrefix + messages.join( '\n ' ) );