forked from daren.hsu/line_push
update
This commit is contained in:
+22
@@ -0,0 +1,22 @@
|
||||
/**
|
||||
Check whether a request can be retried based on the `error.code`.
|
||||
|
||||
@param error - The `.code` property, if it exists, will be used to determine whether retry is allowed.
|
||||
|
||||
@example
|
||||
```
|
||||
import isRetryAllowed = require('is-retry-allowed');
|
||||
|
||||
isRetryAllowed({code: 'ETIMEDOUT'});
|
||||
//=> true
|
||||
|
||||
isRetryAllowed({code: 'ENOTFOUND'});
|
||||
//=> false
|
||||
|
||||
isRetryAllowed({});
|
||||
//=> true
|
||||
```
|
||||
*/
|
||||
declare function isRetryAllowed(error?: Error | Record<string, unknown>): boolean;
|
||||
|
||||
export = isRetryAllowed;
|
||||
+7
-30
@@ -1,21 +1,10 @@
|
||||
'use strict';
|
||||
|
||||
var WHITELIST = [
|
||||
'ETIMEDOUT',
|
||||
'ECONNRESET',
|
||||
'EADDRINUSE',
|
||||
'ESOCKETTIMEDOUT',
|
||||
'ECONNREFUSED',
|
||||
'EPIPE',
|
||||
'EHOSTUNREACH',
|
||||
'EAI_AGAIN'
|
||||
];
|
||||
|
||||
var BLACKLIST = [
|
||||
const denyList = new Set([
|
||||
'ENOTFOUND',
|
||||
'ENETUNREACH',
|
||||
|
||||
// SSL errors from https://github.com/nodejs/node/blob/ed3d8b13ee9a705d89f9e0397d9e96519e7e47ac/src/node_crypto.cc#L1950
|
||||
// SSL errors from https://github.com/nodejs/node/blob/fc8e3e2cdc521978351de257030db0076d79e0ab/src/crypto/crypto_common.cc#L301-L328
|
||||
'UNABLE_TO_GET_ISSUER_CERT',
|
||||
'UNABLE_TO_GET_CRL',
|
||||
'UNABLE_TO_DECRYPT_CERT_SIGNATURE',
|
||||
@@ -42,21 +31,9 @@ var BLACKLIST = [
|
||||
'PATH_LENGTH_EXCEEDED',
|
||||
'INVALID_PURPOSE',
|
||||
'CERT_UNTRUSTED',
|
||||
'CERT_REJECTED'
|
||||
];
|
||||
'CERT_REJECTED',
|
||||
'HOSTNAME_MISMATCH'
|
||||
]);
|
||||
|
||||
module.exports = function (err) {
|
||||
if (!err || !err.code) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (WHITELIST.indexOf(err.code) !== -1) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (BLACKLIST.indexOf(err.code) !== -1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
// TODO: Use `error?.code` when targeting Node.js 14
|
||||
module.exports = error => !denyList.has(error && error.code);
|
||||
|
||||
+5
-16
@@ -1,21 +1,10 @@
|
||||
The MIT License (MIT)
|
||||
MIT License
|
||||
|
||||
Copyright (c) Vsevolod Strukchinsky <floatdrop@gmail.com> (github.com/floatdrop)
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
+39
-26
@@ -1,62 +1,75 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"is-retry-allowed@1.2.0",
|
||||
"/mnt/Foxconn/Digitalent/Deverloper/liff-push_2series"
|
||||
"is-retry-allowed@2.2.0",
|
||||
"/home/node/nuxt"
|
||||
]
|
||||
],
|
||||
"_from": "is-retry-allowed@1.2.0",
|
||||
"_id": "is-retry-allowed@1.2.0",
|
||||
"_from": "is-retry-allowed@2.2.0",
|
||||
"_id": "is-retry-allowed@2.2.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-RUbUeKwvm3XG2VYamhJL1xFktgjvPzL0Hq8C+6yrWIswDy3BIXGqCxhxkc30N9jqK311gVU137K8Ei55/zVJRg==",
|
||||
"_integrity": "sha512-XVm7LOeLpTW4jV19QSH38vkswxoLud8sQ57YwJVTPWdiaI9I8keEhGFpBlslyVsgdQy4Opg8QOLb8YRgsyZiQg==",
|
||||
"_location": "/is-retry-allowed",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "is-retry-allowed@1.2.0",
|
||||
"raw": "is-retry-allowed@2.2.0",
|
||||
"name": "is-retry-allowed",
|
||||
"escapedName": "is-retry-allowed",
|
||||
"rawSpec": "1.2.0",
|
||||
"rawSpec": "2.2.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "1.2.0"
|
||||
"fetchSpec": "2.2.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/axios-retry"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/is-retry-allowed/-/is-retry-allowed-1.2.0.tgz",
|
||||
"_spec": "1.2.0",
|
||||
"_where": "/mnt/Foxconn/Digitalent/Deverloper/liff-push_2series",
|
||||
"_resolved": "https://registry.npmjs.org/is-retry-allowed/-/is-retry-allowed-2.2.0.tgz",
|
||||
"_spec": "2.2.0",
|
||||
"_where": "/home/node/nuxt",
|
||||
"author": {
|
||||
"name": "Vsevolod Strukchinsky",
|
||||
"email": "floatdrop@gmail.com",
|
||||
"url": "github.com/floatdrop"
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "sindresorhus.com"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/floatdrop/is-retry-allowed/issues"
|
||||
"url": "https://github.com/sindresorhus/is-retry-allowed/issues"
|
||||
},
|
||||
"dependencies": {},
|
||||
"description": "Is retry allowed for Error?",
|
||||
"description": "Check whether a request can be retried based on the `error.code`",
|
||||
"devDependencies": {
|
||||
"ava": "^0.8.0",
|
||||
"xo": "^0.12.1"
|
||||
"ava": "^3.14.0",
|
||||
"tsd": "^0.14.0",
|
||||
"xo": "^0.36.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
"node": ">=10"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
"index.js",
|
||||
"index.d.ts"
|
||||
],
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/sindresorhus"
|
||||
},
|
||||
"homepage": "https://github.com/sindresorhus/is-retry-allowed#readme",
|
||||
"keywords": [
|
||||
"retry",
|
||||
"retries",
|
||||
"allowed",
|
||||
"check",
|
||||
"http",
|
||||
"https",
|
||||
"request",
|
||||
"fetch"
|
||||
],
|
||||
"homepage": "https://github.com/floatdrop/is-retry-allowed#readme",
|
||||
"keywords": [],
|
||||
"license": "MIT",
|
||||
"name": "is-retry-allowed",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/floatdrop/is-retry-allowed.git"
|
||||
"url": "git+https://github.com/sindresorhus/is-retry-allowed.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava"
|
||||
"test": "xo && ava && tsd"
|
||||
},
|
||||
"version": "1.2.0"
|
||||
"version": "2.2.0"
|
||||
}
|
||||
|
||||
+14
-10
@@ -1,7 +1,6 @@
|
||||
# is-retry-allowed [](https://travis-ci.org/floatdrop/is-retry-allowed)
|
||||
|
||||
Is retry allowed for Error?
|
||||
# is-retry-allowed
|
||||
|
||||
> Check whether a request can be retried based on the `error.code`
|
||||
|
||||
## Install
|
||||
|
||||
@@ -9,7 +8,6 @@ Is retry allowed for Error?
|
||||
$ npm install --save is-retry-allowed
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
@@ -25,18 +23,24 @@ isRetryAllowed({});
|
||||
//=> true
|
||||
```
|
||||
|
||||
|
||||
## API
|
||||
|
||||
### isRetryAllowed(error)
|
||||
|
||||
#### error
|
||||
|
||||
Type: `object`
|
||||
Type: `Error | object`
|
||||
|
||||
Object with `code` property, which will be used to determine retry.
|
||||
The `.code` property, if it exists, will be used to determine whether retry is allowed.
|
||||
|
||||
---
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Vsevolod Strukchinsky](http://github.com/floatdrop)
|
||||
<div align="center">
|
||||
<b>
|
||||
<a href="https://tidelift.com/subscription/pkg/npm-is-retry-allowed?utm_source=npm-is-retry-allowed&utm_medium=referral&utm_campaign=readme">Get professional support for this package with a Tidelift subscription</a>
|
||||
</b>
|
||||
<br>
|
||||
<sub>
|
||||
Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
|
||||
</sub>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user