Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions src/raven.js
Original file line number Diff line number Diff line change
Expand Up @@ -668,10 +668,7 @@ function processException(type, message, fileurl, lineno, frames, options) {
if (!!globalOptions.ignoreErrors.test && globalOptions.ignoreErrors.test(message)) return;

message += '';
message = truncate(message, globalOptions.maxMessageLength);

fullMessage = type + ': ' + message;
fullMessage = truncate(fullMessage, globalOptions.maxMessageLength);

if (frames && frames.length) {
fileurl = frames[0].filename || fileurl;
Expand Down Expand Up @@ -723,6 +720,19 @@ function truncate(str, max) {
return str.length <= max ? str : str.substr(0, max) + '\u2026';
}

function trimPacket(data) {
// For now, we only want to truncate the two different messages
// but this could/should be expanded to just trim everything
var max = globalOptions.maxMessageLength;
data.message = truncate(data.message, max);
if (data.exception) {
var exception = data.exception.values[0];
exception.value = truncate(exception.value, max);
}

return data;
}

function now() {
return +new Date();
}
Expand Down Expand Up @@ -799,6 +809,9 @@ function send(data) {
// Set lastEventId after we know the error should actually be sent
lastEventId = data.event_id || (data.event_id = uuid4());

// Try and clean up the packet before sending by truncating long values
data = trimPacket(data);

logDebug('debug', 'Raven about to send:', data);

if (!isSetup()) return;
Expand Down
Loading