Skip to content

Commit 37883c1

Browse files
committed
fix(api): catch sync request errors
1 parent 27e4080 commit 37883c1

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

lib/agent/api/index.js

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,20 @@ function CollectorApi (options) {
3232
// USE THIS WITH CAUTION, IT WILL BE BLOCKING
3333
CollectorApi.prototype._sendSync = function (destinationUrl, data) {
3434
debug('sending data to trace servers sync: ', JSON.stringify(data))
35-
requestSync('POST', destinationUrl, {
36-
json: data,
37-
headers: {
38-
'Authorization': 'Bearer ' + this.apiKey,
39-
'Content-Type': 'application/json',
40-
'X-Reporter-Version': libPackage.version,
41-
'X-Reporter-Language': this.collectorLanguage
42-
},
43-
timeout: 1000
44-
})
35+
try {
36+
requestSync('POST', destinationUrl, {
37+
json: data,
38+
headers: {
39+
'Authorization': 'Bearer ' + this.apiKey,
40+
'Content-Type': 'application/json',
41+
'X-Reporter-Version': libPackage.version,
42+
'X-Reporter-Language': this.collectorLanguage
43+
},
44+
timeout: 1000
45+
})
46+
} catch (ex) {
47+
debug('error sending data to trace servers sync: ', ex)
48+
}
4549
}
4650

4751
CollectorApi.prototype._withInstanceInfo = function (data) {

0 commit comments

Comments
 (0)