@bugsnag/delivery-electron
Advanced tools
Comparing version 7.19.0 to 7.22.1
@@ -8,10 +8,30 @@ const { createHash } = require('crypto') | ||
const delivery = (client, filestore, net, app) => { | ||
const noop = () => {} | ||
const send = (opts, body, cb) => { | ||
const errorHandler = err => { | ||
err.isRetryable = true | ||
cb(err) | ||
let errorCallback = (error, response) => { | ||
// an error can still happen on both the request and response even after a response is received, | ||
// so we noop on subsequent calls to ensure this is only handled once | ||
errorCallback = noop | ||
if (response) { | ||
error.isRetryable = isRetryable(response.statusCode) | ||
// do not retry oversized payloads regardless of status code | ||
if (body.length > 10e5) { | ||
client._logger.warn(`Discarding over-sized event (${(body.length / 10e5).toFixed(2)} MB) after failed delivery`) | ||
error.isRetryable = false | ||
} | ||
} else { | ||
error.isRetryable = true | ||
} | ||
cb(error) | ||
} | ||
const req = net.request(opts, response => { | ||
req.removeListener('error', errorHandler) | ||
// handle errors on the response stream | ||
response.on('error', err => { | ||
errorCallback(err, response) | ||
}) | ||
if (isOk(response)) { | ||
@@ -21,13 +41,7 @@ cb(null) | ||
const err = new Error(`Bad status code from API: ${response.statusCode}`) | ||
err.isRetryable = isRetryable(response.statusCode) | ||
// do not retry oversized payloads regardless of status code | ||
if (body.length > 10e5) { | ||
client._logger.warn(`Discarding over-sized event (${(body.length / 10e5).toFixed(2)} MB) after failed delivery`) | ||
err.isRetryable = false | ||
} | ||
cb(err) | ||
errorCallback(err, response) | ||
} | ||
}) | ||
req.on('error', errorHandler) | ||
req.on('error', err => errorCallback(err)) | ||
@@ -34,0 +48,0 @@ try { |
{ | ||
"name": "@bugsnag/delivery-electron", | ||
"version": "7.19.0", | ||
"version": "7.22.1", | ||
"main": "delivery.js", | ||
@@ -28,3 +28,3 @@ "description": "@bugsnag/electron delivery mechanism to send events, sessions, and crash dumps from Electron apps", | ||
}, | ||
"gitHead": "95d2c3dd978e7dc5a6fda5664cfa9cf437b03b76" | ||
"gitHead": "73cb5c474b6134a3a0c367d8abc3991c25d9d443" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
14149
370