Skip to content

Commit

Permalink
Merge branch 'release/7.41.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
codenirvana committed Aug 16, 2024
2 parents cc81d10 + 5379e80 commit 9ede743
Show file tree
Hide file tree
Showing 7 changed files with 132 additions and 11 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
7.41.2:
date: 2024-08-16
fixed bugs:
- Fixed a bug where script host was not disposed after the run
chores:
- GH-1443 Added support for `agentIdleTimeout` configuration

7.41.1:
date: 2024-08-06
chores:
Expand Down
1 change: 1 addition & 0 deletions lib/requester/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,7 @@ module.exports = {
options.agents = defaultOpts.agents;
options.extraCA = defaultOpts.extendedRootCA;
options.ignoreProxyEnvironmentVariables = defaultOpts.ignoreProxyEnvironmentVariables;
options.agentIdleTimeout = defaultOpts.agentIdleTimeout;

// Disable encoding of URL in postman-request in order to use pre-encoded URL object returned from
// toNodeUrl() function of postman-url-encoder
Expand Down
1 change: 1 addition & 0 deletions lib/requester/requester-pool.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ RequesterPool = function (options, callback) {
strictSSL: _.get(options, 'requester.strictSSL'),
maxResponseSize: _.get(options, 'requester.maxResponseSize'),
protocolVersion: _.get(options, 'requester.protocolVersion'),
agentIdleTimeout: _.get(options, 'requester.agentIdleTimeout', 60 * 1000), // 60 seconds
// @todo drop support in v8
useWhatWGUrlParser: _.get(options, 'requester.useWhatWGUrlParser', false),
insecureHTTPParser: _.get(options, 'requester.insecureHTTPParser'),
Expand Down
3 changes: 3 additions & 0 deletions lib/runner/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,9 @@ _.assign(Run.prototype, {

// if there is nothing to process, exit
if (!instruction) {
// dispose the host before ending the run
this.host && this.host.dispose();

callback(null, this.state.cursor.current());

return;
Expand Down
18 changes: 9 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "postman-runtime",
"version": "7.41.1",
"version": "7.41.2",
"description": "Underlying library of executing Postman Collections",
"author": "Postman Inc.",
"license": "Apache-2.0",
Expand Down Expand Up @@ -55,7 +55,7 @@
"node-oauth1": "1.3.0",
"performance-now": "2.1.0",
"postman-collection": "4.5.0",
"postman-request": "2.88.1-postman.38",
"postman-request": "2.88.1-postman.39",
"postman-sandbox": "5.1.1",
"postman-url-encoder": "3.0.5",
"serialised-error": "1.1.3",
Expand Down
109 changes: 109 additions & 0 deletions test/integration/requester-spec/agentIdleTimout.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
var expect = require('chai').expect;

(typeof window === 'undefined' ? describe : describe.skip)('Requester Spec: agentIdleTimeout', function () {
var testrun,
URL = 'https://postman-echo.com/get',
collection = {
item: [{
request: {
url: URL,
method: 'GET'
}
}, {
request: {
url: URL,
method: 'GET'
}
}]
};

describe('with no time gap between requests', function () {
before(function (done) {
this.run({
collection
}, function (err, results) {
testrun = results;
done(err);
});
});

it('should have secureConnect time as zero', function () {
var response = testrun.response.getCall(1).args[2],
history = testrun.request.getCall(1).args[6],
timings;

expect(history).to.have.property('execution').that.include.property('data');
timings = history.execution.data[0].timings;

expect(response).to.have.property('responseTime');
expect(timings.offset.secureConnect - timings.offset.lookup).to.equal(0);
});
});
describe('with time gap greater than agentIdleTimeout between requests', function () {
before(function (done) {
const newCollection = JSON.parse(JSON.stringify(collection));

newCollection.item[1].event = [{
listen: 'prerequest',
script: { exec: [
'setTimeout(function () {}, 500);'
] }
}];
this.run({
collection: newCollection,
requester: {
agentIdleTimeout: 100
}
}, function (err, results) {
testrun = results;
done(err);
});
});

it('should have secureConnect time greater than zero', function () {
var response = testrun.response.getCall(1).args[2],
history = testrun.request.getCall(1).args[6],
timings;

expect(history).to.have.property('execution').that.include.property('data');
timings = history.execution.data[0].timings;

expect(response).to.have.property('responseTime');
expect(timings.offset.secureConnect - timings.offset.lookup).greaterThan(0);
});
});

describe('with time gap less than agentIdleTimeout between requests', function () {
before(function (done) {
const newCollection = JSON.parse(JSON.stringify(collection));

newCollection.item[1].event = [{
listen: 'prerequest',
script: { exec: [
'setTimeout(function () {}, 100);'
] }
}];
this.run({
collection: newCollection,
requester: {
agentIdleTimeout: 1000
}
}, function (err, results) {
testrun = results;
done(err);
});
});

it('should have secureConnect time zero', function () {
var response = testrun.response.getCall(1).args[2],
history = testrun.request.getCall(1).args[6],
timings;

expect(history).to.have.property('execution').that.include.property('data');
timings = history.execution.data[0].timings;

expect(response).to.have.property('responseTime');
expect(timings.offset.secureConnect - timings.offset.lookup).equal(0);
});
});
});

0 comments on commit 9ede743

Please sign in to comment.