Skip to content

Commit

Permalink
Increase stack trace limit for Errors created by assert - see #9
Browse files Browse the repository at this point in the history
  • Loading branch information
matthew-blackman committed May 14, 2024
1 parent 9c7053e commit c09f0b7
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions js/assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 ' ) );
}
};
Expand Down

0 comments on commit c09f0b7

Please sign in to comment.