@@ -668,10 +668,7 @@ function processException(type, message, fileurl, lineno, frames, options) {
668668 if ( ! ! globalOptions . ignoreErrors . test && globalOptions . ignoreErrors . test ( message ) ) return ;
669669
670670 message += '' ;
671- message = truncate ( message , globalOptions . maxMessageLength ) ;
672-
673671 fullMessage = type + ': ' + message ;
674- fullMessage = truncate ( fullMessage , globalOptions . maxMessageLength ) ;
675672
676673 if ( frames && frames . length ) {
677674 fileurl = frames [ 0 ] . filename || fileurl ;
@@ -723,6 +720,19 @@ function truncate(str, max) {
723720 return str . length <= max ? str : str . substr ( 0 , max ) + '\u2026' ;
724721}
725722
723+ function trimPacket ( data ) {
724+ // For now, we only want to truncate the two different messages
725+ // but this could/should be expanded to just trim everything
726+ var max = globalOptions . maxMessageLength ;
727+ data . message = truncate ( data . message , max ) ;
728+ if ( data . exception ) {
729+ var exception = data . exception . values [ 0 ] ;
730+ exception . value = truncate ( exception . value , max ) ;
731+ }
732+
733+ return data ;
734+ }
735+
726736function now ( ) {
727737 return + new Date ( ) ;
728738}
@@ -797,6 +807,9 @@ function send(data) {
797807 // Set lastEventId after we know the error should actually be sent
798808 lastEventId = data . event_id || ( data . event_id = uuid4 ( ) ) ;
799809
810+ // Try and clean up the packet before sending by truncating long values
811+ data = trimPacket ( data ) ;
812+
800813 logDebug ( 'debug' , 'Raven about to send:' , data ) ;
801814
802815 if ( ! isSetup ( ) ) return ;
0 commit comments