Socket
Socket
Sign inDemoInstall

azure-iot-common

Package Overview
Dependencies
4
Maintainers
8
Versions
114
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.12.11 to 1.12.12

4

dist/retry_operation.d.ts

@@ -11,2 +11,4 @@ import { RetryPolicy } from './retry_policy';

private _operationExpiryTime;
private _name;
private _id;
/**

@@ -17,3 +19,3 @@ * Creates an instance of {@link azure-iot-common.RetryOperation.}

*/
constructor(policy: RetryPolicy, maxTimeout: number);
constructor(name: string, policy: RetryPolicy, maxTimeout: number);
/**

@@ -20,0 +22,0 @@ * Executes an operation and retries if it fails and the retry policy allows it.

@@ -8,2 +8,4 @@ // Copyright (c) Microsoft. All rights reserved.

var debug = dbg('azure-iot-common:RetryOperation');
var debugErrors = dbg('azure-iot-common:RetryOperation:Errors');
var _nextId = 0;
/**

@@ -18,5 +20,8 @@ * Implements the necessary logic to retry operations such as connecting, receiving C2D messages, sending telemetry, twin updates, etc.

*/
function RetryOperation(policy, maxTimeout) {
function RetryOperation(name, policy, maxTimeout) {
this._retryCount = 0;
this._name = '';
this._id = 0;
if (policy && policy.constructor && policy.constructor.name === 'NoRetry') {
// Do not remove this line. It is here at the request of CSS.
debug('A RetryOperation is being used with a NoRetry policy. The operation will not be retried on failure.');

@@ -26,2 +31,5 @@ }

this._maxTimeout = maxTimeout;
this._name = name;
this._id = _nextId;
_nextId += 1;
}

@@ -36,2 +44,3 @@ /**

var _this = this;
var _a;
var retryOperation = function () {

@@ -48,7 +57,7 @@ _this._retryCount++;

if (Date.now() >= _this._operationExpiryTime || nextRetryTimeout < 0) {
debug('Past the maximum timeout for the operation. failing with the latest error.');
debugErrors(_this._name + ":" + _this._id + " Past the maximum timeout for the operation. failing with the latest error: " + err.toString() + ".");
finalCallback(err);
}
else {
debug('Will retry after: ' + nextRetryTimeout + ' milliseconds');
debug(_this._name + ":" + _this._id + " Will retry after: " + nextRetryTimeout + " milliseconds");
setTimeout(retryOperation, nextRetryTimeout);

@@ -58,3 +67,3 @@ }

else {
debug('Error: ' + err.toString() + ' is not retriable');
debugErrors(_this._name + ":" + _this._id + " Error: " + err.toString() + " is not retriable");
/*Codes_SRS_NODE_COMMON_RETRY_OPERATION_16_004: [If the `operation` fails and should not be retried, the `finalCallback` should be called with the last error as the only parameter. ]*/

@@ -66,2 +75,3 @@ finalCallback(err);

/*Codes_SRS_NODE_COMMON_RETRY_OPERATION_16_002: [If the `operation` is successful the `finalCallback` function should be called with a `null` error parameter and the result of the operation.]*/
debug(_this._name + ":" + _this._id + " Complete");
finalCallback(null, result, response);

@@ -73,3 +83,3 @@ }

this._operationExpiryTime = this._operationStartTime + this._maxTimeout;
debug('Operation start time: ' + this._operationStartTime + ' - Will stop retrying after: ' + this._operationExpiryTime);
debug(this._name + ":" + this._id + ":" + ((_a = this._policy) === null || _a === void 0 ? void 0 : _a.constructor.name) + " Operation started at " + this._operationStartTime + " - Will stop retrying after: " + this._operationExpiryTime);
retryOperation();

@@ -76,0 +86,0 @@ };

{
"name": "azure-iot-common",
"version": "1.12.11",
"version": "1.12.12",
"description": "Common components shared by Azure IoT device and service SDKs",

@@ -18,3 +18,3 @@ "author": "Microsoft Corporation",

"chai": "^4.3.3",
"mocha": "^7.1.1",
"mocha": "^9.1.2",
"nyc": "^15.0.0",

@@ -21,0 +21,0 @@ "sinon": "^11.1.2",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc