@applitools/req
Advanced tools
Comparing version 1.7.6 to 1.7.7
# Changelog | ||
## [1.7.7](https://github.com/Applitools-Dev/sdk/compare/js/req@1.7.6...js/req@1.7.7) (2025-01-19) | ||
### Bug Fixes | ||
* memory usage going high when resource is uint8array ([#2743](https://github.com/Applitools-Dev/sdk/issues/2743)) ([d06deeb](https://github.com/Applitools-Dev/sdk/commit/d06deeb845de62e96ec623efefa90ae65a703736)) | ||
## [1.7.6](https://github.com/Applitools-Dev/sdk/compare/js/req@1.7.5...js/req@1.7.6) (2024-12-31) | ||
@@ -4,0 +11,0 @@ |
@@ -51,3 +51,3 @@ import { AbortController } from 'abort-controller'; | ||
const requestController = new AbortController(); | ||
const timeout = calculateTimeout(options.requestTimeout, options.body); | ||
const timeout = calculateTimeout(options.requestTimeout, options.body, options); | ||
const requestTimer = timeout | ||
@@ -256,3 +256,4 @@ ? setTimeout(() => { | ||
} | ||
function calculateTimeout(requestTimeout, body) { | ||
function calculateTimeout(requestTimeout, body, options) { | ||
var _a; | ||
if (!requestTimeout) | ||
@@ -270,2 +271,6 @@ return requestTimeout; | ||
return base + perByte * body.byteLength; | ||
if (utils.types.instanceOf(body, Uint8Array) || | ||
utils.types.instanceOf(body, Uint16Array) || | ||
utils.types.instanceOf(body, Uint32Array)) | ||
return base + perByte * body.byteLength; | ||
if (global.Blob && utils.types.instanceOf(body, Blob)) | ||
@@ -275,15 +280,10 @@ return base + perByte * body.size; | ||
return base + perByte * body.byteLength; | ||
try { | ||
return base + perByte * JSON.stringify(body).length; | ||
} | ||
catch (error) { | ||
try { | ||
return base + perByte * String(body).length; | ||
} | ||
catch (error) { | ||
return base + perByte * 1; | ||
} | ||
} | ||
const allHooks = ((_a = options === null || options === void 0 ? void 0 : options.hooks) !== null && _a !== void 0 ? _a : []); | ||
allHooks.forEach(hooks => { | ||
var _a; | ||
(_a = hooks.unknownBodyType) === null || _a === void 0 ? void 0 : _a.call(hooks, { body, options }); | ||
}); | ||
return base + perByte * 10; | ||
} | ||
return requestTimeout; | ||
} |
{ | ||
"name": "@applitools/req", | ||
"version": "1.7.6", | ||
"version": "1.7.7", | ||
"description": "Applitools fetch-based request library", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -139,2 +139,3 @@ export type Stop = typeof stop; | ||
afterError?(options: { request: Request; error: Error; options?: undefined | TOptions; }): void | Error | PromiseLike<void | Error>; | ||
unknownBodyType?(options: { body: TOptions["body"]; options?: undefined | TOptions; }): void; | ||
} | ||
@@ -141,0 +142,0 @@ export type AbortSignal = { readonly aborted: boolean; onabort: null | ((event: any) => void); addEventListener: (type: "abort", listener: () => void) => void; removeEventListener: (type: "abort", listener: () => void) => void; }; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
443779
10368