Comparing version 4.3.1 to 4.3.2
@@ -14,3 +14,3 @@ "use strict"; | ||
var _serializeError = _interopRequireDefault(require("serialize-error")); | ||
var _serializeError = require("serialize-error"); | ||
@@ -150,11 +150,30 @@ var _Logger = _interopRequireDefault(require("../Logger")); | ||
for (var _i = 0, _shutdownHandlers = shutdownHandlers; _i < _shutdownHandlers.length; _i++) { | ||
const shutdownHandler = _shutdownHandlers[_i]; | ||
var _iteratorNormalCompletion = true; | ||
var _didIteratorError = false; | ||
var _iteratorError = undefined; | ||
try { | ||
for (var _iterator = shutdownHandlers[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { | ||
const shutdownHandler = _step.value; | ||
try { | ||
yield shutdownHandler(); | ||
} catch (error) { | ||
log.error({ | ||
error: (0, _serializeError.serializeError)(error) | ||
}, 'shutdown handler produced an error'); | ||
} | ||
} | ||
} catch (err) { | ||
_didIteratorError = true; | ||
_iteratorError = err; | ||
} finally { | ||
try { | ||
yield shutdownHandler(); | ||
} catch (error) { | ||
log.error({ | ||
error: (0, _serializeError.default)(error) | ||
}, 'shutdown handler produced an error'); | ||
if (!_iteratorNormalCompletion && _iterator.return != null) { | ||
_iterator.return(); | ||
} | ||
} finally { | ||
if (_didIteratorError) { | ||
throw _iteratorError; | ||
} | ||
} | ||
@@ -167,3 +186,3 @@ } | ||
log.error({ | ||
error: (0, _serializeError.default)(error) | ||
error: (0, _serializeError.serializeError)(error) | ||
}, 'server was terminated with an error'); | ||
@@ -190,9 +209,9 @@ } | ||
} else { | ||
var _iteratorNormalCompletion = true; | ||
var _didIteratorError = false; | ||
var _iteratorError = undefined; | ||
var _iteratorNormalCompletion2 = true; | ||
var _didIteratorError2 = false; | ||
var _iteratorError2 = undefined; | ||
try { | ||
for (var _iterator = configuration.signals[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { | ||
const signal = _step.value; | ||
for (var _iterator2 = configuration.signals[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) { | ||
const signal = _step2.value; | ||
process.on(signal, () => { | ||
@@ -206,12 +225,12 @@ log.debug({ | ||
} catch (err) { | ||
_didIteratorError = true; | ||
_iteratorError = err; | ||
_didIteratorError2 = true; | ||
_iteratorError2 = err; | ||
} finally { | ||
try { | ||
if (!_iteratorNormalCompletion && _iterator.return != null) { | ||
_iterator.return(); | ||
if (!_iteratorNormalCompletion2 && _iterator2.return != null) { | ||
_iterator2.return(); | ||
} | ||
} finally { | ||
if (_didIteratorError) { | ||
throw _iteratorError; | ||
if (_didIteratorError2) { | ||
throw _iteratorError2; | ||
} | ||
@@ -218,0 +237,0 @@ } |
@@ -24,27 +24,27 @@ { | ||
"express": "^4.17.1", | ||
"roarr": "^2.13.2", | ||
"serialize-error": "^4.1.0" | ||
"roarr": "^2.14.2", | ||
"serialize-error": "^5.0.0" | ||
}, | ||
"description": "Abstracts readiness/ liveness checks and graceful shutdown of Node.js services running in Kubernetes.", | ||
"devDependencies": { | ||
"@babel/cli": "^7.5.5", | ||
"@babel/core": "^7.5.5", | ||
"@babel/node": "^7.5.5", | ||
"@babel/plugin-transform-flow-strip-types": "^7.4.4", | ||
"@babel/preset-env": "^7.5.5", | ||
"@babel/register": "^7.5.5", | ||
"ava": "^2.2.0", | ||
"@babel/cli": "^7.6.4", | ||
"@babel/core": "^7.6.4", | ||
"@babel/node": "^7.6.3", | ||
"@babel/plugin-transform-flow-strip-types": "^7.6.3", | ||
"@babel/preset-env": "^7.6.3", | ||
"@babel/register": "^7.6.2", | ||
"ava": "^2.4.0", | ||
"axios": "^0.19.0", | ||
"babel-plugin-istanbul": "^5.2.0", | ||
"coveralls": "^3.0.5", | ||
"eslint": "^6.1.0", | ||
"eslint-config-canonical": "^17.3.0", | ||
"flow-bin": "^0.104.0", | ||
"flow-copy-source": "^2.0.7", | ||
"coveralls": "^3.0.7", | ||
"eslint": "^6.6.0", | ||
"eslint-config-canonical": "^17.7.0", | ||
"flow-bin": "^0.110.1", | ||
"flow-copy-source": "^2.0.8", | ||
"get-port": "^5.0.0", | ||
"gitdown": "^3.1.1", | ||
"husky": "^3.0.1", | ||
"gitdown": "^3.1.2", | ||
"husky": "^3.0.9", | ||
"nyc": "^14.1.1", | ||
"semantic-release": "^15.13.18", | ||
"sinon": "^7.3.2" | ||
"semantic-release": "^15.13.28", | ||
"sinon": "^7.5.0" | ||
}, | ||
@@ -88,3 +88,3 @@ "engines": { | ||
}, | ||
"version": "4.3.1" | ||
"version": "4.3.2" | ||
} |
@@ -29,2 +29,3 @@ <a name="lightship"></a> | ||
* [FAQ](#lightship-faq) | ||
* [What is the reason that my liveness/ readiness endpoints are intermittently failing?](#lightship-faq-what-is-the-reason-that-my-liveness-readiness-endpoints-are-intermittently-failing) | ||
* [What is the reason for having separate `/live` and `/ready` endpoints?](#lightship-faq-what-is-the-reason-for-having-separate-live-and-ready-endpoints) | ||
@@ -428,2 +429,39 @@ * [Related projects](#lightship-related-projects) | ||
<a name="lightship-faq-what-is-the-reason-that-my-liveness-readiness-endpoints-are-intermittently-failing"></a> | ||
### What is the reason that my liveness/ readiness endpoints are intermittently failing? | ||
You may discover that your service health checks are failing intermittently, e.g. | ||
``` | ||
Warning Unhealthy 4m17s (x3 over 4m27s) kubelet, f95a4d94-jwfr Liveness probe failed: Get http://10.24.7.155:9000/live: net/http: request canceled (Client.Timeout exceeded while awaiting headers) | ||
Warning Unhealthy 3m28s (x15 over 4m38s) kubelet, f95a4d94-jwfr Readiness probe failed: Get http://10.24.7.155:9000/ready: net/http: request canceled (Client.Timeout exceeded while awaiting headers) | ||
``` | ||
This may happen if you are perfoming [event-loop blocking tasks](https://nodejs.org/ru/docs/guides/dont-block-the-event-loop/) for extended durations, e.g. | ||
```js | ||
const startTime = Date.now(); | ||
let index0 = 1000; | ||
while (index0--) { | ||
let index1 = 1000; | ||
while (index1--) { | ||
console.log(index0 + ':' + index1); | ||
} | ||
} | ||
console.log(Date.now() - startTime); | ||
``` | ||
If executed, the above operation would block the event-loop for couple of seconds (e.g. 8 seconds on my machine). During this time Lightship is going to be unresponsive. | ||
Your options are: | ||
* Use [`worker_threads`](https://nodejs.org/api/worker_threads.html) to execute the event-loop blocking task in the background. | ||
* Refactor the code into [synchronous chunks](https://nodejs.org/ru/docs/guides/dont-block-the-event-loop/). | ||
<a name="lightship-faq-what-is-the-reason-for-having-separate-live-and-ready-endpoints"></a> | ||
@@ -430,0 +468,0 @@ ### What is the reason for having separate <code>/live</code> and <code>/ready</code> endpoints? |
@@ -7,3 +7,5 @@ // @flow | ||
import express from 'express'; | ||
import serializeError from 'serialize-error'; | ||
import { | ||
serializeError, | ||
} from 'serialize-error'; | ||
import Logger from '../Logger'; | ||
@@ -10,0 +12,0 @@ import type { |
@@ -22,3 +22,3 @@ // @flow | ||
+signals?: $ReadOnlyArray<string>, | ||
+timeout?: number | ||
+timeout?: number, | ||
|}; | ||
@@ -30,3 +30,3 @@ | ||
+signals: $ReadOnlyArray<string>, | ||
+timeout: number | ||
+timeout: number, | ||
|}; | ||
@@ -38,3 +38,3 @@ | ||
export type BeaconControllerType = {| | ||
+die: () => Promise<void> | ||
+die: () => Promise<void>, | ||
|}; | ||
@@ -62,3 +62,3 @@ | ||
+signalNotReady: () => void, | ||
+signalReady: () => void | ||
+signalReady: () => void, | ||
|}; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
62795
577
475
+ Addedserialize-error@5.0.0(transitive)
+ Addedtype-fest@0.8.1(transitive)
- Removedserialize-error@4.1.0(transitive)
- Removedtype-fest@0.3.1(transitive)
Updatedroarr@^2.14.2
Updatedserialize-error@^5.0.0