@pact-foundation/pact-core
Advanced tools
Comparing version 11.0.0 to 11.0.1
@@ -5,2 +5,10 @@ # Changelog | ||
### [11.0.1](https://github.com/pact-foundation/pact-js-core/compare/v11.0.0...v11.0.1) (2021-06-21) | ||
### Fixes and Improvements | ||
* Allow the user to specify the timeout (Fixes [#298](https://github.com/pact-foundation/pact-js-core/issues/298)) ([4c77ddb](https://github.com/pact-foundation/pact-js-core/commit/4c77ddb7071672050fd682e27992b37cb0682bb6)) | ||
* update standalone to 1.88.56 ([81821fc](https://github.com/pact-foundation/pact-js-core/commit/81821fcd53649aedd242c9a2a4578b16c4c1fcd6)) | ||
## [11.0.0](https://github.com/pact-foundation/pact-js-core/compare/v10.12.1...v11.0.0) (2021-05-21) | ||
@@ -7,0 +15,0 @@ |
{ | ||
"name": "@pact-foundation/pact-core", | ||
"version": "11.0.0", | ||
"version": "11.0.1", | ||
"description": "Core of @pact-foundation/pact. You almost certainly don't want to depend on this directly.", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -192,2 +192,3 @@ <img src="https://raw.githubusercontent.com/pact-foundation/pact-logo/master/media/logo-black.png" width="200"> | ||
| `out` | false | string | Write output to a file instead of returning it in the promise, defaults to none | | ||
| `timeout` | false | number | How long to wait for the mock server to start up (in milliseconds). Defaults to 30000 (30 seconds) | | ||
@@ -422,3 +423,5 @@ #### List Mock Servers | ||
| cors | false | boolean | Allow CORS OPTION requests to be accepted, defaults to 'false' | | ||
| timeout | false | number | How long to wait for the stub server to start up (in milliseconds). Defaults to 30000 (30 seconds) | | ||
### Message Pacts | ||
@@ -425,0 +428,0 @@ |
@@ -22,3 +22,4 @@ import { AbstractService, LogLevel } from './service'; | ||
logLevel?: LogLevel; | ||
timeout?: number; | ||
pactFileWriteMode?: 'overwrite' | 'update' | 'merge'; | ||
} |
@@ -36,2 +36,3 @@ /// <reference types="node" /> | ||
logLevel?: LogLevel; | ||
timeout?: number; | ||
} | ||
@@ -38,0 +39,0 @@ export declare type LogLevel = 'debug' | 'info' | 'warn' | 'error'; |
@@ -29,5 +29,9 @@ "use strict"; | ||
var setTimeout = global.setTimeout; | ||
var CHECKTIME = 500; | ||
var RETRY_AMOUNT = 60; | ||
var PROCESS_TIMEOUT = 30000; | ||
var getTimeout = function (options) { | ||
return options.timeout || 30000; | ||
}; | ||
var getRetryTickTime = function (options) { | ||
return Math.round(getTimeout(options) / RETRY_AMOUNT); | ||
}; | ||
var AbstractService = (function (_super) { | ||
@@ -54,3 +58,5 @@ __extends(AbstractService, _super); | ||
checkTypes.assert.positive(options.port); | ||
checkTypes.assert.inRange(options.port, 0, 65535); | ||
if (!checkTypes.inRange(options.port, 0, 65535)) { | ||
throw new Error("Port number " + options.port + " is not in the range 0-65535"); | ||
} | ||
if (checkTypes.not.inRange(options.port, 1024, 49151)) { | ||
@@ -139,3 +145,3 @@ logger_1.default.warn('Like a Boss, you used a port outside of the recommended range (1024 to 49151); I too like to live dangerously.'); | ||
}); | ||
return promise_timeout_1.timeout(this.__waitForServiceUp(), PROCESS_TIMEOUT) | ||
return promise_timeout_1.timeout(this.__waitForServiceUp(), getTimeout(this.options)) | ||
.then(function () { | ||
@@ -148,3 +154,3 @@ _this.__running = true; | ||
if (err instanceof promise_timeout_1.TimeoutError) { | ||
throw new Error("Couldn't start Pact with PID: " + (_this.__instance ? _this.__instance.pid : 'No Instance')); | ||
throw new Error("Timeout while waiting to start Pact with PID: " + (_this.__instance ? _this.__instance.pid : 'No Instance')); | ||
} | ||
@@ -159,6 +165,6 @@ throw err; | ||
.then(spawn_1.default.killBinary) | ||
.then(function () { return _this.__waitForServiceDown(); }), PROCESS_TIMEOUT) | ||
.then(function () { return _this.__waitForServiceDown(); }), getTimeout(this.options)) | ||
.catch(function (err) { | ||
if (err instanceof promise_timeout_1.TimeoutError) { | ||
throw new Error("Couldn't stop Pact with PID '" + pid + "'"); | ||
throw new Error("Timeout while waiting to stop Pact with PID '" + pid + "'"); | ||
} | ||
@@ -189,5 +195,5 @@ throw err; | ||
if (amount >= RETRY_AMOUNT) { | ||
reject(new Error('Pact startup failed; tried calling service 10 times with no result.')); | ||
reject(new Error("Pact startup failed; tried calling service " + RETRY_AMOUNT + " times with no result.")); | ||
} | ||
setTimeout(check.bind(_this), CHECKTIME); | ||
setTimeout(check.bind(_this), getRetryTickTime(_this.options)); | ||
}; | ||
@@ -216,6 +222,6 @@ var check = function () { | ||
if (amount >= RETRY_AMOUNT) { | ||
reject(new Error('Pact stop failed; tried calling service 10 times with no result.')); | ||
reject(new Error("Pact stop failed; tried calling service " + RETRY_AMOUNT + " times with no result.")); | ||
return; | ||
} | ||
setTimeout(check, CHECKTIME); | ||
setTimeout(check, getRetryTickTime(_this.options)); | ||
}, function () { return resolve(); }); | ||
@@ -222,0 +228,0 @@ } |
@@ -18,2 +18,3 @@ import { AbstractService, LogLevel } from './service'; | ||
logLevel?: LogLevel; | ||
timeout?: number; | ||
} |
@@ -1,2 +0,2 @@ | ||
export declare const PACT_STANDALONE_VERSION = "1.88.51"; | ||
export declare const PACT_STANDALONE_VERSION = "1.88.56"; | ||
export declare function createConfig(location?: string): Config; | ||
@@ -3,0 +3,0 @@ export declare function getBinaryEntry(platform?: string, arch?: string): BinaryEntry; |
@@ -30,3 +30,3 @@ "use strict"; | ||
}); | ||
exports.PACT_STANDALONE_VERSION = '1.88.51'; | ||
exports.PACT_STANDALONE_VERSION = '1.88.56'; | ||
var PACT_DEFAULT_LOCATION = "https://github.com/pact-foundation/pact-ruby-standalone/releases/download/v" + exports.PACT_STANDALONE_VERSION + "/"; | ||
@@ -33,0 +33,0 @@ var HTTP_REGEX = /^http(s?):\/\//; |
Sorry, the diff of this file is not supported yet
277320
3612
514