A variety of logging improvements to track down bugs (#1832)
* Log when we get a blocked numbers sync message * Save three old signed keys in addition to the current active * Remove the mystery from all the error-related log messages * Log successful load of signed key - to help debug prekey errors * removeSignedPreKey: Don't hang or crash in error cases * Log on top-level unhandled promise rejection * Remove trailing comma in param list, Electron 1.6 does not like * Harden top-level error handler for strange object shapes
This commit is contained in:
parent
a5923c2177
commit
44da6924f9
7 changed files with 28 additions and 10 deletions
|
@ -559,8 +559,7 @@
|
|||
|
||||
function onError(ev) {
|
||||
var error = ev.error;
|
||||
console.log(error);
|
||||
console.log(error.stack);
|
||||
console.log('background onError:', error && error.stack ? error.stack : error);
|
||||
|
||||
if (error.name === 'HTTPError' && (error.code == 401 || error.code == 403)) {
|
||||
Whisper.Registration.remove();
|
||||
|
|
|
@ -38049,7 +38049,7 @@ var TextSecureServer = (function() {
|
|||
console.log("Old signed prekey record count: " + oldRecords.length);
|
||||
|
||||
oldRecords.forEach(function(oldRecord) {
|
||||
if ( oldRecord.keyId > activeSignedPreKeyId - 3 ) {
|
||||
if ( oldRecord.keyId >= activeSignedPreKeyId - 3 ) {
|
||||
// keep at least the last 3 signed keys
|
||||
return;
|
||||
}
|
||||
|
@ -39151,6 +39151,7 @@ MessageReceiver.prototype.extend({
|
|||
}.bind(this));
|
||||
},
|
||||
handleBlocked: function(envelope, blocked) {
|
||||
console.log('Setting these numbers as blocked:', blocked.numbers);
|
||||
textsecure.storage.put('blocked', blocked.numbers);
|
||||
},
|
||||
isBlocked: function(number) {
|
||||
|
|
|
@ -161,6 +161,10 @@ window.log = {
|
|||
};
|
||||
|
||||
window.onerror = function(message, script, line, col, error) {
|
||||
window.log.error(error.stack);
|
||||
const errorInfo = error && error.stack ? error.stack : JSON.stringify(error);
|
||||
window.log.error('Top-level unhandled error: ' + errorInfo);
|
||||
};
|
||||
|
||||
window.addEventListener('unhandledrejection', function(rejectionEvent) {
|
||||
window.log.error('Top-level unhandled promise rejection: ' + rejectionEvent.reason);
|
||||
});
|
||||
|
|
|
@ -314,8 +314,11 @@
|
|||
errors = [errors];
|
||||
}
|
||||
errors.forEach(function(e) {
|
||||
console.log(e);
|
||||
console.log(e.reason, e.stack);
|
||||
console.log(
|
||||
'Message.saveErrors:',
|
||||
e && e.reason ? e.reason : null,
|
||||
e && e.stack ? e.stack : e
|
||||
);
|
||||
});
|
||||
errors = errors.map(function(e) {
|
||||
if (e.constructor === Error ||
|
||||
|
|
|
@ -211,7 +211,16 @@
|
|||
this.trigger('removePreKey');
|
||||
|
||||
return new Promise(function(resolve) {
|
||||
prekey.destroy().then(function() {
|
||||
var deferred = prekey.destroy();
|
||||
if (!deferred) {
|
||||
return resolve();
|
||||
}
|
||||
|
||||
return deferred.then(resolve, function(error) {
|
||||
console.log(
|
||||
'removePreKey error:',
|
||||
error && error.stack ? error.stack : error
|
||||
);
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
|
@ -222,6 +231,7 @@
|
|||
var prekey = new SignedPreKey({id: keyId});
|
||||
return new Promise(function(resolve) {
|
||||
prekey.fetch().then(function() {
|
||||
console.log('Successfully loaded prekey:', prekey.get('id'));
|
||||
resolve({
|
||||
pubKey : prekey.get('publicKey'),
|
||||
privKey : prekey.get('privateKey'),
|
||||
|
@ -229,14 +239,14 @@
|
|||
keyId : prekey.get('id')
|
||||
});
|
||||
}).fail(function() {
|
||||
console.log("Failed to load signed prekey:", keyId);
|
||||
console.log('Failed to load signed prekey:', keyId);
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
},
|
||||
loadSignedPreKeys: function() {
|
||||
if (arguments.length > 0) {
|
||||
return Promise.reject(new Error("loadSignedPreKeys takes no arguments"));
|
||||
return Promise.reject(new Error('loadSignedPreKeys takes no arguments'));
|
||||
}
|
||||
var signedPreKeys = new SignedPreKeyCollection();
|
||||
return new Promise(function(resolve) {
|
||||
|
|
|
@ -179,7 +179,7 @@
|
|||
console.log("Old signed prekey record count: " + oldRecords.length);
|
||||
|
||||
oldRecords.forEach(function(oldRecord) {
|
||||
if ( oldRecord.keyId > activeSignedPreKeyId - 3 ) {
|
||||
if ( oldRecord.keyId >= activeSignedPreKeyId - 3 ) {
|
||||
// keep at least the last 3 signed keys
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -730,6 +730,7 @@ MessageReceiver.prototype.extend({
|
|||
}.bind(this));
|
||||
},
|
||||
handleBlocked: function(envelope, blocked) {
|
||||
console.log('Setting these numbers as blocked:', blocked.numbers);
|
||||
textsecure.storage.put('blocked', blocked.numbers);
|
||||
},
|
||||
isBlocked: function(number) {
|
||||
|
|
Loading…
Reference in a new issue