mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-08-20 11:31:45 +02:00
.devcontainer
.github
.vscode
build
client
docs
images
server
controllers
finders
libs
archiver
async
bcryptjs
busboy
commandLineArgs
dateAndTime
expressFileupload
fastSort
ffbinaries
fluentFfmpeg
fsExtra
imageType
isexe
jsonwebtoken
jwa
jws
libarchive
lodash.once
ms
nodeCron
nodeFfprobe
nodeStreamZip
passportLocal
readChunk
recursiveReaddirAsync
requestIp
rss
sanitizeHtml
streamsearch
uaParser
universalify
watcher
aborter
atomically
utils
attemptify.js
fs.js
fs_handlers.js
lang.js
retryify.js
retryify_queue.js
scheduler.js
temp.js
consts.js
index.js
ripstat
LICENSE
are-shallow-equal.js
constants.js
debounce.js
enums.js
is-primitive.js
promise-concurrency-limiter.js
string-indexes.js
tiny-readdir.js
types.js
utils.js
watcher.js
watcher_handler.js
watcher_locker.js
watcher_locks_resolver.js
watcher_poller.js
watcher_stats.js
which
xml
managers
models
objects
providers
routers
scanner
utils
Auth.js
Database.js
Logger.js
Server.js
SocketAuthority.js
Watcher.js
test
.dockerignore
.editorconfig
.gitattributes
.gitignore
.prettierrc
Dockerfile
LICENSE
custom-metadata-provider-specification.yaml
docker-compose.yml
docker-template.xml
index.js
package-lock.json
package.json
prod.js
readme.md
46 lines
1.6 KiB
JavaScript
46 lines
1.6 KiB
JavaScript
"use strict";
|
|
/* IMPORT */
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.retryifySync = exports.retryifyAsync = void 0;
|
|
const retryify_queue_1 = require("./retryify_queue");
|
|
/* RETRYIFY */
|
|
const retryifyAsync = (fn, isRetriableError) => {
|
|
return function (timestamp) {
|
|
return function attempt() {
|
|
return retryify_queue_1.default.schedule().then(cleanup => {
|
|
return fn.apply(undefined, arguments).then(result => {
|
|
cleanup();
|
|
return result;
|
|
}, error => {
|
|
cleanup();
|
|
if (Date.now() >= timestamp)
|
|
throw error;
|
|
if (isRetriableError(error)) {
|
|
const delay = Math.round(100 + (400 * Math.random())), delayPromise = new Promise(resolve => setTimeout(resolve, delay));
|
|
return delayPromise.then(() => attempt.apply(undefined, arguments));
|
|
}
|
|
throw error;
|
|
});
|
|
});
|
|
};
|
|
};
|
|
};
|
|
exports.retryifyAsync = retryifyAsync;
|
|
const retryifySync = (fn, isRetriableError) => {
|
|
return function (timestamp) {
|
|
return function attempt() {
|
|
try {
|
|
return fn.apply(undefined, arguments);
|
|
}
|
|
catch (error) {
|
|
if (Date.now() > timestamp)
|
|
throw error;
|
|
if (isRetriableError(error))
|
|
return attempt.apply(undefined, arguments);
|
|
throw error;
|
|
}
|
|
};
|
|
};
|
|
};
|
|
exports.retryifySync = retryifySync;
|