Comparing version 1.0.0 to 1.1.0
@@ -22,2 +22,3 @@ const { Resource } = require('./Resource'); | ||
'acquireTimeoutMillis', | ||
'propagateCreateError', | ||
'createTimeoutMillis', | ||
@@ -100,2 +101,3 @@ 'idleTimeoutMillis', | ||
this.createRetryIntervalMillis = opt.createRetryIntervalMillis || 200; | ||
this.propagateCreateError = !!opt.propagateCreateError; | ||
@@ -290,2 +292,13 @@ this.min = opt.min; | ||
.catch(err => { | ||
if (this.propagateCreateError && this.pendingAcquires.length !== 0) { | ||
// If propagateCreateError is true, we don't retry the create | ||
// but reject the first pending acquire immediately. Intentionally | ||
// use `this.pendingAcquires` instead of `pendingAcquiresBeforeCreate` | ||
// in case some acquires in pendingAcquiresBeforeCreate have already | ||
// been resolved. | ||
this.pendingAcquires[0].reject(err); | ||
} | ||
// Save the create error to all pending acquires so that we can use it | ||
// as the error to reject the acquire if it times out. | ||
pendingAcquiresBeforeCreate.forEach(pendingAcquire => { | ||
@@ -292,0 +305,0 @@ pendingAcquire.possibleTimeoutCause = err; |
{ | ||
"name": "tarn", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "Simple and robust resource pool for node.js", | ||
@@ -23,12 +23,4 @@ "main": "lib/tarn.js", | ||
}, | ||
"keywords": [ | ||
"pool", | ||
"pooling", | ||
"throttle" | ||
], | ||
"files": [ | ||
"README.md", | ||
"LICENSE", | ||
"lib/*" | ||
], | ||
"keywords": ["pool", "pooling", "throttle"], | ||
"files": ["README.md", "LICENSE", "lib/*"], | ||
"devDependencies": { | ||
@@ -35,0 +27,0 @@ "bluebird": "^3.5.1", |
@@ -65,3 +65,9 @@ [![Build Status](https://travis-ci.org/Vincit/tarn.js.svg?branch=master)](https://travis-ci.org/Vincit/tarn.js) | ||
// long long to idle after failed create before trying again | ||
createRetryIntervalMillis: 200 | ||
createRetryIntervalMillis: 200, | ||
// If true, when a create fails, the first pending acquire is | ||
// rejected with the error. If this is false (the default) then | ||
// create is retried until acquireTimeoutMillis milliseconds has | ||
// passed. | ||
propagateCreateError: false | ||
}); | ||
@@ -68,0 +74,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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
18172
475
111
0