aws-rum-web
Advanced tools
Comparing version 1.17.2 to 1.18.0
@@ -5,2 +5,13 @@ # Changelog | ||
## [1.18.0](https://github.com/aws-observability/aws-rum-web/compare/v1.17.0...v1.18.0) (2024-05-29) | ||
### Features | ||
* keep alive when dispatch fails ([#524](https://github.com/aws-observability/aws-rum-web/issues/524)) ([87e4cb4](https://github.com/aws-observability/aws-rum-web/commit/87e4cb4eee9810823de0458a4c8c6158a1732c08)) | ||
* keep alive when dispatch fails with 401 ([#551](https://github.com/aws-observability/aws-rum-web/issues/551)) ([b9823bd](https://github.com/aws-observability/aws-rum-web/commit/b9823bd8e7ffe31f95d011abfa417183abeb2f89)) | ||
* keep earliest event when cache is full ([#537](https://github.com/aws-observability/aws-rum-web/issues/537)) ([339ab09](https://github.com/aws-observability/aws-rum-web/commit/339ab09c9e365fb0db6917a36ed4b5fb80d7183d)) | ||
* limit retries to 5xx and 429 ([#500](https://github.com/aws-observability/aws-rum-web/issues/500)) ([df90602](https://github.com/aws-observability/aws-rum-web/commit/df906023e81bfcd53c7b7e26abd4af531af353de)) | ||
* retry with exponential backoff ([#501](https://github.com/aws-observability/aws-rum-web/issues/501)) ([59904c8](https://github.com/aws-observability/aws-rum-web/commit/59904c8e00b2827e127a0a041908e152222a73cc)) | ||
### [1.17.2](https://github.com/aws-observability/aws-rum-web/compare/v1.17.1...v1.17.2) (2024-04-03) | ||
@@ -7,0 +18,0 @@ |
@@ -15,2 +15,3 @@ import { AwsCredentialIdentityProvider, AwsCredentialIdentity, HttpResponse } from '@aws-sdk/types'; | ||
private config; | ||
private disableCodes; | ||
constructor(region: string, endpoint: URL, eventCache: EventCache, config: Config); | ||
@@ -17,0 +18,0 @@ /** |
@@ -49,2 +49,3 @@ "use strict"; | ||
var _this = this; | ||
this.disableCodes = ['403', '404']; | ||
/** | ||
@@ -102,6 +103,8 @@ * Send meta data and events to the AWS RUM data plane service via fetch. | ||
this.handleReject = function (e) { | ||
// The handler has run out of retries. We adhere to our convention to | ||
// fail safe by disabling dispatch. This ensures that we will not | ||
// continue to attempt requests when the problem is not recoverable. | ||
_this.disable(); | ||
if (e instanceof Error && _this.disableCodes.includes(e.message)) { | ||
// RUM disables only when dispatch fails and we are certain | ||
// that subsequent attempts will not succeed, such as when | ||
// credentials are invalid or the app monitor does not exist. | ||
_this.disable(); | ||
} | ||
throw e; | ||
@@ -108,0 +111,0 @@ }; |
@@ -18,3 +18,2 @@ import { HttpHandler, HttpRequest, HttpResponse } from '@aws-sdk/protocol-http'; | ||
private sleep; | ||
private isStatusCode2xx; | ||
} |
@@ -40,2 +40,3 @@ "use strict"; | ||
exports.RetryHttpHandler = void 0; | ||
var http_utils_1 = require("../plugins/utils/http-utils"); | ||
/** | ||
@@ -49,6 +50,3 @@ * An HttpHandler which wraps other HttpHandlers to retry requests. | ||
function RetryHttpHandler(handler, retries, backoff) { | ||
if (backoff === void 0) { backoff = function (n) { return n * 2000; }; } | ||
this.isStatusCode2xx = function (statusCode) { | ||
return statusCode >= 200 && statusCode < 300; | ||
}; | ||
if (backoff === void 0) { backoff = function (n) { return 2000 * Math.pow(2, n - 1); }; } | ||
this.handler = handler; | ||
@@ -74,9 +72,14 @@ this.retries = retries; | ||
response = _a.sent(); | ||
if (this.isStatusCode2xx(response.response.statusCode)) { | ||
if ((0, http_utils_1.is2xx)(response.response.statusCode)) { | ||
return [2 /*return*/, response]; | ||
} | ||
throw new Error("".concat(response.response.statusCode)); | ||
throw response.response.statusCode; | ||
case 4: | ||
e_1 = _a.sent(); | ||
if (!retriesLeft) { | ||
if (typeof e_1 === 'number' && !(0, http_utils_1.is429)(e_1) && !(0, http_utils_1.is5xx)(e_1)) { | ||
// Fail immediately on client errors because they will never succeed. | ||
// Only retry when request is throttled (429) or received server error (5xx). | ||
throw new Error("".concat(e_1)); | ||
} | ||
if (retriesLeft <= 0) { | ||
throw e_1; | ||
@@ -83,0 +86,0 @@ } |
@@ -19,3 +19,3 @@ "use strict"; | ||
var EventBus_1 = require("../event-bus/EventBus"); | ||
var webClientVersion = '1.17.2'; | ||
var webClientVersion = '1.18.0'; | ||
/** | ||
@@ -106,4 +106,7 @@ * A cache which stores events generated by telemetry plugins. | ||
if (_this.events.length === _this.config.eventCacheSize) { | ||
// Make room in the cache by dropping the oldest event. | ||
_this.events.shift(); | ||
// Drop newest event and keep the older ones | ||
// 1. Older events tend to be more relevant, such as session start | ||
// or performance entries that are attributed to web vitals | ||
// 2. Dropping an old event requires linear time | ||
return; | ||
} | ||
@@ -110,0 +113,0 @@ // The data plane service model (i.e., LogEvents) does not adhere to the |
@@ -18,2 +18,3 @@ import { Http, Subsegment, XRayTraceEvent } from '../../events/xray-trace-event'; | ||
export declare const defaultConfig: HttpPluginConfig; | ||
export declare const is2xx: (status: number) => boolean; | ||
export declare const is4xx: (status: number) => boolean; | ||
@@ -20,0 +21,0 @@ export declare const is5xx: (status: number) => boolean; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.resourceToUrlString = exports.getTraceHeader = exports.getAmznTraceIdHeaderValue = exports.addAmznTraceIdHeaderToHeaders = exports.addAmznTraceIdHeaderToInit = exports.requestInfoToHostname = exports.createXRaySubsegment = exports.createXRayTraceEvent = exports.createXRayTraceEventHttp = exports.epochTime = exports.isUrlAllowed = exports.is429 = exports.is5xx = exports.is4xx = exports.defaultConfig = exports.isTraceIdHeaderEnabled = exports.X_AMZN_TRACE_ID = exports.byteToHex = void 0; | ||
exports.resourceToUrlString = exports.getTraceHeader = exports.getAmznTraceIdHeaderValue = exports.addAmznTraceIdHeaderToHeaders = exports.addAmznTraceIdHeaderToInit = exports.requestInfoToHostname = exports.createXRaySubsegment = exports.createXRayTraceEvent = exports.createXRayTraceEventHttp = exports.epochTime = exports.isUrlAllowed = exports.is429 = exports.is5xx = exports.is4xx = exports.is2xx = exports.defaultConfig = exports.isTraceIdHeaderEnabled = exports.X_AMZN_TRACE_ID = exports.byteToHex = void 0; | ||
var random_1 = require("../../utils/random"); | ||
@@ -31,2 +31,4 @@ // All one-byte hex strings from 0x00 to 0xff. | ||
}; | ||
var is2xx = function (status) { return 200 <= status && status < 300; }; | ||
exports.is2xx = is2xx; | ||
var is4xx = function (status) { | ||
@@ -33,0 +35,0 @@ return Math.floor(status / 100) === 4; |
@@ -15,2 +15,3 @@ import { AwsCredentialIdentityProvider, AwsCredentialIdentity, HttpResponse } from '@aws-sdk/types'; | ||
private config; | ||
private disableCodes; | ||
constructor(region: string, endpoint: URL, eventCache: EventCache, config: Config); | ||
@@ -17,0 +18,0 @@ /** |
@@ -46,2 +46,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
var _this = this; | ||
this.disableCodes = ['403', '404']; | ||
/** | ||
@@ -99,6 +100,8 @@ * Send meta data and events to the AWS RUM data plane service via fetch. | ||
this.handleReject = function (e) { | ||
// The handler has run out of retries. We adhere to our convention to | ||
// fail safe by disabling dispatch. This ensures that we will not | ||
// continue to attempt requests when the problem is not recoverable. | ||
_this.disable(); | ||
if (e instanceof Error && _this.disableCodes.includes(e.message)) { | ||
// RUM disables only when dispatch fails and we are certain | ||
// that subsequent attempts will not succeed, such as when | ||
// credentials are invalid or the app monitor does not exist. | ||
_this.disable(); | ||
} | ||
throw e; | ||
@@ -105,0 +108,0 @@ }; |
@@ -18,3 +18,2 @@ import { HttpHandler, HttpRequest, HttpResponse } from '@aws-sdk/protocol-http'; | ||
private sleep; | ||
private isStatusCode2xx; | ||
} |
@@ -37,2 +37,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
}; | ||
import { is2xx, is429, is5xx } from '../plugins/utils/http-utils'; | ||
/** | ||
@@ -46,6 +47,3 @@ * An HttpHandler which wraps other HttpHandlers to retry requests. | ||
function RetryHttpHandler(handler, retries, backoff) { | ||
if (backoff === void 0) { backoff = function (n) { return n * 2000; }; } | ||
this.isStatusCode2xx = function (statusCode) { | ||
return statusCode >= 200 && statusCode < 300; | ||
}; | ||
if (backoff === void 0) { backoff = function (n) { return 2000 * Math.pow(2, n - 1); }; } | ||
this.handler = handler; | ||
@@ -71,9 +69,14 @@ this.retries = retries; | ||
response = _a.sent(); | ||
if (this.isStatusCode2xx(response.response.statusCode)) { | ||
if (is2xx(response.response.statusCode)) { | ||
return [2 /*return*/, response]; | ||
} | ||
throw new Error("".concat(response.response.statusCode)); | ||
throw response.response.statusCode; | ||
case 4: | ||
e_1 = _a.sent(); | ||
if (!retriesLeft) { | ||
if (typeof e_1 === 'number' && !is429(e_1) && !is5xx(e_1)) { | ||
// Fail immediately on client errors because they will never succeed. | ||
// Only retry when request is throttled (429) or received server error (5xx). | ||
throw new Error("".concat(e_1)); | ||
} | ||
if (retriesLeft <= 0) { | ||
throw e_1; | ||
@@ -80,0 +83,0 @@ } |
@@ -16,3 +16,3 @@ var __assign = (this && this.__assign) || function () { | ||
import EventBus, { Topic } from '../event-bus/EventBus'; | ||
var webClientVersion = '1.17.2'; | ||
var webClientVersion = '1.18.0'; | ||
/** | ||
@@ -103,4 +103,7 @@ * A cache which stores events generated by telemetry plugins. | ||
if (_this.events.length === _this.config.eventCacheSize) { | ||
// Make room in the cache by dropping the oldest event. | ||
_this.events.shift(); | ||
// Drop newest event and keep the older ones | ||
// 1. Older events tend to be more relevant, such as session start | ||
// or performance entries that are attributed to web vitals | ||
// 2. Dropping an old event requires linear time | ||
return; | ||
} | ||
@@ -107,0 +110,0 @@ // The data plane service model (i.e., LogEvents) does not adhere to the |
@@ -18,2 +18,3 @@ import { Http, Subsegment, XRayTraceEvent } from '../../events/xray-trace-event'; | ||
export declare const defaultConfig: HttpPluginConfig; | ||
export declare const is2xx: (status: number) => boolean; | ||
export declare const is4xx: (status: number) => boolean; | ||
@@ -20,0 +21,0 @@ export declare const is5xx: (status: number) => boolean; |
@@ -27,2 +27,3 @@ import { getRandomValues } from '../../utils/random'; | ||
}; | ||
export var is2xx = function (status) { return 200 <= status && status < 300; }; | ||
export var is4xx = function (status) { | ||
@@ -29,0 +30,0 @@ return Math.floor(status / 100) === 4; |
@@ -15,2 +15,3 @@ import { AwsCredentialIdentityProvider, AwsCredentialIdentity, HttpResponse } from '@aws-sdk/types'; | ||
private config; | ||
private disableCodes; | ||
constructor(region: string, endpoint: URL, eventCache: EventCache, config: Config); | ||
@@ -17,0 +18,0 @@ /** |
@@ -18,3 +18,2 @@ import { HttpHandler, HttpRequest, HttpResponse } from '@aws-sdk/protocol-http'; | ||
private sleep; | ||
private isStatusCode2xx; | ||
} |
@@ -18,2 +18,3 @@ import { Http, Subsegment, XRayTraceEvent } from '../../events/xray-trace-event'; | ||
export declare const defaultConfig: HttpPluginConfig; | ||
export declare const is2xx: (status: number) => boolean; | ||
export declare const is4xx: (status: number) => boolean; | ||
@@ -20,0 +21,0 @@ export declare const is5xx: (status: number) => boolean; |
{ | ||
"name": "aws-rum-web", | ||
"version": "1.17.2", | ||
"version": "1.18.0", | ||
"sideEffects": false, | ||
@@ -5,0 +5,0 @@ "description": "The Amazon CloudWatch RUM web client.", |
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
1360426
16812