Commit 98cfca3adda0b43df56e76c6332bc19ee7ff5a87
1 parent
3b71ec6743
Exists in
master
more try catch to debug
Showing 1 changed file with 31 additions and 14 deletions Side-by-side Diff
matrix-util.js
... | ... | @@ -127,26 +127,43 @@ MatrixUtil.prototype._updateLastResponseTime = function(partner) { |
127 | 127 | let matrix = this.matrix; |
128 | 128 | let logger = this.logger; |
129 | 129 | |
130 | - if (!matrix.buddies[partner]['last_outgoing']) { | |
131 | - logger.verbose('No outgoing yet, skip updateLastResponseTime'); | |
132 | - return; | |
130 | + try { | |
131 | + if (!matrix.buddies[partner]['last_outgoing']) { | |
132 | + logger.verbose('No outgoing yet, skip updateLastResponseTime'); | |
133 | + return; | |
134 | + } | |
135 | + | |
136 | + if (!matrix.buddies[partner]['last_outgoing']['last_update_ts']) { | |
137 | + logger.verbose('No outgoing timestamp yet, skip updateLastResponseTime'); | |
138 | + return; | |
139 | + } | |
140 | + } | |
141 | + catch(e) { | |
142 | + logger.warn('Exception when preparing updateLastResponseTime', {err: e}); | |
133 | 143 | } |
134 | 144 | |
135 | - if (!matrix.buddies[partner]['last_outgoing']['last_update_ts']) { | |
136 | - logger.verbose('No outgoing timestamp yet, skip updateLastResponseTime'); | |
137 | - return; | |
145 | + try { | |
146 | + if ( | |
147 | + matrix.buddies[partner]['last_incoming'] | |
148 | + && (Number(matrix.buddies[partner]['last_incoming']['last_update_ts']) > Number(matrix.buddies[partner]['last_outgoing']['last_update_ts'])) | |
149 | + ) { | |
150 | + return; | |
151 | + } | |
152 | + } | |
153 | + catch(e) { | |
154 | + logger.warn('Exception when checking if last_incoming > last_outgoing', {err: e}); | |
138 | 155 | } |
139 | 156 | |
140 | - if ( | |
141 | - matrix.buddies[partner]['last_incoming'] | |
142 | - && (Number(matrix.buddies[partner]['last_incoming']['last_update_ts']) > Number(matrix.buddies[partner]['last_outgoing']['last_update_ts'])) | |
143 | - ) { | |
144 | - return; | |
157 | + | |
158 | + try { | |
159 | + let delta = Date.now() - Number(matrix.buddies[partner]['last_outgoing']['last_update_ts']); | |
160 | + logger.verbose('Response time in ' + delta + 'ms'); | |
161 | + matrix.buddies[partner]['last_response_time'] = Math.round(delta/1000); | |
162 | + } | |
163 | + catch(e) { | |
164 | + logger.warn('Exception when calculating last_response_time', {err: e}); | |
145 | 165 | } |
146 | 166 | |
147 | - let delta = Date.now() - Number(matrix.buddies[partner]['last_outgoing']['last_update_ts']); | |
148 | - logger.verbose('Response time in ' + delta + 'ms'); | |
149 | - matrix.buddies[partner]['last_response_time'] = Math.round(delta/1000); | |
150 | 167 | } |
151 | 168 | |
152 | 169 | MatrixUtil.prototype._updateLastMessage = function(partner, msg, direction) { |