@applitools/execution-grid-client
Advanced tools
Comparing version 1.1.10 to 1.1.11
@@ -38,3 +38,3 @@ "use strict"; | ||
return async function proxyRequest({ request, response, options, logger, }) { | ||
var _a, _b, _c, _d, _e; | ||
var _a, _b, _c, _d, _e, _f; | ||
options = Object.assign(Object.assign({}, defaultOptions), options); | ||
@@ -48,3 +48,3 @@ const isProxyRequest = !options.url && /^http/.test(request.url); | ||
headers: Object.assign(Object.assign({}, request.headers), options.headers), | ||
body: options.body, | ||
body: (_b = options.body) !== null && _b !== void 0 ? _b : request, | ||
proxy: options.proxy, | ||
@@ -54,9 +54,6 @@ signal: options.signal, | ||
requestOptions.headers.host = new URL(isProxyRequest ? request.url : options.url).host; | ||
if (requestOptions.body && !utils.types.isFunction(requestOptions.body, 'pipe')) { | ||
if (!utils.types.isFunction(requestOptions.body, 'pipe')) { | ||
requestOptions.headers['Content-Length'] = Buffer.byteLength(requestOptions.body).toString(); | ||
} | ||
else { | ||
requestOptions.body = request; | ||
} | ||
const modifiedRequestOptions = (_c = (await ((_b = options.modifyRequest) === null || _b === void 0 ? void 0 : _b.call(options, requestOptions)))) !== null && _c !== void 0 ? _c : requestOptions; | ||
const modifiedRequestOptions = (_d = (await ((_c = options.modifyRequest) === null || _c === void 0 ? void 0 : _c.call(options, requestOptions)))) !== null && _d !== void 0 ? _d : requestOptions; | ||
let proxyResponse; | ||
@@ -66,6 +63,6 @@ for (let attempt = 1; attempt <= 10; ++attempt) { | ||
proxyResponse = await send(modifiedRequestOptions); | ||
if (!(await ((_d = options.shouldRetry) === null || _d === void 0 ? void 0 : _d.call(options, proxyResponse)))) | ||
if (!(await ((_e = options.shouldRetry) === null || _e === void 0 ? void 0 : _e.call(options, proxyResponse)))) | ||
break; | ||
logger.error(`Attempt (${attempt}) to proxy request finished with unexpected status ${proxyResponse.statusCode}`); | ||
await utils.general.sleep((_e = options.retryTimeout) !== null && _e !== void 0 ? _e : 5000); | ||
await utils.general.sleep((_f = options.retryTimeout) !== null && _f !== void 0 ? _f : 5000); | ||
} | ||
@@ -76,3 +73,3 @@ catch (error) { | ||
logger.error(`Attempt (${attempt}) to proxy request failed with error`, error); | ||
if (attempt + 1 <= 10) | ||
if (attempt + 1 >= 10) | ||
throw error; | ||
@@ -99,3 +96,11 @@ } | ||
if (requestOptions.body && utils.types.isFunction(requestOptions.body, 'pipe')) { | ||
requestOptions.body.pipe(request); | ||
const chunks = []; | ||
requestOptions.body.on('data', chunk => { | ||
chunks.push(chunk); | ||
request.write(chunk); | ||
}); | ||
requestOptions.body.on('end', () => { | ||
requestOptions.body = Buffer.concat(chunks); | ||
request.end(); | ||
}); | ||
} | ||
@@ -102,0 +107,0 @@ else { |
{ | ||
"name": "@applitools/execution-grid-client", | ||
"version": "1.1.10", | ||
"version": "1.1.11", | ||
"description": "", | ||
@@ -45,2 +45,3 @@ "license": "SEE LICENSE IN LICENSE", | ||
"test": "mocha --no-timeouts -r ts-node/register ./test/**/*.spec.ts", | ||
"test:e2e": "mocha --no-timeouts -r ts-node/register ./test/e2e/*.spec.ts", | ||
"deps": "bongo deps", | ||
@@ -57,3 +58,3 @@ "preversion": "bongo preversion && yarn build", | ||
"dependencies": { | ||
"@applitools/logger": "1.1.3", | ||
"@applitools/logger": "1.1.4", | ||
"@applitools/utils": "1.3.0", | ||
@@ -60,0 +61,0 @@ "abort-controller": "3.0.0", |
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
47047
670
+ Added@applitools/logger@1.1.4(transitive)
- Removed@applitools/logger@1.1.3(transitive)
Updated@applitools/logger@1.1.4