@@ -11,6 +11,7 @@ export class ConsoleCatcher {
1111 private readonly MAX_LOGS = 20 ;
1212 private readonly consoleOutput : ConsoleLogEvent [ ] = [ ] ;
1313 private isInitialized = false ;
14+ private isProcessing = false ;
1415
1516 /**
1617 * Converts any argument to its string representation
@@ -131,6 +132,11 @@ export class ConsoleCatcher {
131132 const oldFunction = window . console [ method ] . bind ( window . console ) ;
132133
133134 window . console [ method ] = ( ...args : unknown [ ] ) : void => {
135+ // Prevent recursive calls
136+ if ( this . isProcessing ) {
137+ return oldFunction ( ...args ) ;
138+ }
139+
134140 /**
135141 * If the console call originates from Vue's internal runtime bundle, skip interception
136142 * to avoid capturing Vue-internal warnings and causing recursive loops.
@@ -140,20 +146,34 @@ export class ConsoleCatcher {
140146 return oldFunction ( ...args ) ;
141147 }
142148
143- const stack = new Error ( ) . stack ?. split ( '\n' ) . slice ( 2 ) . join ( '\n' ) || '' ;
144- const { message, styles } = this . formatConsoleArgs ( args ) ;
149+ // Additional protection against Hawk internal calls
150+ if ( rawStack . includes ( 'hawk.javascript' ) || rawStack . includes ( '@hawk.so' ) ) {
151+ return oldFunction ( ...args ) ;
152+ }
145153
146- const logEvent : ConsoleLogEvent = {
147- method,
148- timestamp : new Date ( ) ,
149- type : method ,
150- message,
151- stack,
152- fileLine : stack . split ( '\n' ) [ 0 ] ?. trim ( ) ,
153- styles,
154- } ;
154+ this . isProcessing = true ;
155+
156+ try {
157+ const stack = new Error ( ) . stack ?. split ( '\n' ) . slice ( 2 ) . join ( '\n' ) || '' ;
158+ const { message, styles } = this . formatConsoleArgs ( args ) ;
159+
160+ const logEvent : ConsoleLogEvent = {
161+ method,
162+ timestamp : new Date ( ) ,
163+ type : method ,
164+ message,
165+ stack,
166+ fileLine : stack . split ( '\n' ) [ 0 ] ?. trim ( ) ,
167+ styles,
168+ } ;
169+
170+ this . addToConsoleOutput ( logEvent ) ;
171+ } catch ( error ) {
172+ // Silently ignore errors in console processing to prevent infinite loops
173+ } finally {
174+ this . isProcessing = false ;
175+ }
155176
156- this . addToConsoleOutput ( logEvent ) ;
157177 oldFunction ( ...args ) ;
158178 } ;
159179 } ) ;
0 commit comments