Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (config.org.debug) {
console.log("\n------------------------------");
console.log("emacsclient: ", config.org.emacsclient);
console.log("emacs_lisp: \n", emacs_lisp);
console.log("\n------------------------------");
}
// Remove triling garbages
emacs_lisp = fix_elisp(emacs_lisp);
var exec_args = ['-nw', '-s', 'hexo-renderer-org', '-e', emacs_lisp];
// if (config.org.export_cfg != '')
// exec_args.splice(1,0,'--execute', config.org.export_cfg);
var operation = retry.operation( {
retries: 100,
factor: 2,
minTimeout: 100,
maxTimeout: 1000,
randomize: true
});
operation.attempt(function (currentAttempt) {
var proc = child_process.spawn(config.org.emacsclient, exec_args, {
stdio: 'inherit'
});
function retryOrExit(err) {
if (config.org.debug)
console.log("RETRY: ", data.path);
if (_.isUndefined(renderedQuery)) {
debugLog.push(req, 'No query to call ES with. Skipping');
return next();
}
// options for retry
// maxRetries is from the API config with default of 3
// factor of 1 means that each retry attempt will esclient requestTimeout
const operationOptions = {
retries: _.get(apiConfig, 'requestRetries', 3),
factor: 1,
minTimeout: _.get(esclient, 'transport.requestTimeout')
};
// setup a new operation
const operation = retry.operation(operationOptions);
// elasticsearch command
const cmd = {
index: apiConfig.indexName,
searchType: 'dfs_query_then_fetch',
body: renderedQuery.body
};
logger.debug( '[ES req]', cmd );
debugLog.push(req, {ES_req: cmd});
operation.attempt((currentAttempt) => {
const initialTime = debugLog.beginTimer(req, `Attempt ${currentAttempt}`);
// query elasticsearch
searchService( esclient, cmd, function( err, docs, meta ){
// returns true if the operation should be attempted again
function download (url, file, options) {
var operation;
var response;
var deferred = Q.defer();
var progressDelay = 8000;
options = mout.object.mixIn({
retries: 5,
factor: 2,
minTimeout: 1000,
maxTimeout: 35000,
randomize: true
}, options || {});
// Retry on network errors
operation = retry.operation(options);
operation.attempt(function () {
var req;
var writeStream;
var contentLength;
var bytesDownloaded = 0;
req = progress(request(url, options), {
delay: progressDelay
})
.on('response', function (res) {
var status = res.statusCode;
if (status < 200 || status >= 300) {
return deferred.reject(createError('Status code of ' + status, 'EHTTP'));
}
function addRemoteTarball_(u, tmp, shasum, cb) {
// Tuned to spread 3 attempts over about a minute.
// See formula at .
var operation = retry.operation
( { retries: npm.config.get("fetch-retries")
, factor: npm.config.get("fetch-retry-factor")
, minTimeout: npm.config.get("fetch-retry-mintimeout")
, maxTimeout: npm.config.get("fetch-retry-maxtimeout") })
operation.attempt(function (currentAttempt) {
log.info("retry", "fetch attempt " + currentAttempt
+ " at " + (new Date()).toLocaleTimeString())
fetchAndShaCheck(u, tmp, shasum, function (er, response, shasum) {
// Only retry on 408, 5xx or no `response`.
var sc = response && response.statusCode
var statusRetry = !sc || (sc === 408 || sc >= 500)
if (er && statusRetry && operation.retry(er)) {
log.info("retry", "will retry, error on last attempt: " + er)
return
}
if (_.isUndefined(renderedQuery)) {
debugLog.push(req, `No query to call ES with. Skipping`);
return next();
}
// options for retry
// maxRetries is from the API config with default of 3
// factor of 1 means that each retry attempt will esclient requestTimeout
const operationOptions = {
retries: _.get(apiConfig, 'requestRetries', 3),
factor: 1,
minTimeout: _.get(esclient, 'transport.requestTimeout')
};
// setup a new operation
const operation = retry.operation(operationOptions);
// elasticsearch command
const cmd = {
index: apiConfig.indexName,
searchType: 'dfs_query_then_fetch',
body: renderedQuery.body
};
logger.debug( '[ES req]', cmd );
debugLog.push(req, {ES_req: cmd});
operation.attempt((currentAttempt) => {
const initialTime = debugLog.beginTimer(req, `Attempt ${currentAttempt}`);
// query elasticsearch
searchService( esclient, cmd, function( err, docs, meta, data ){
const message = {
function executeAction(promiseFactoryMethod) {
let operation = retry.operation({
retries: 3,
minTimeout: 1000
});
let errorHandler = (reject, error) => {
logger.error(error.toString(true));
if ((error instanceof HttpRequestError) && operation.retry(error)) reject(error);
if (operation.mainError() !== null) {
reject(operation.mainError());
} else {
reject(error.toString(true));
}
};
return new Promise((resolve, reject) => {
operation.attempt(() => {
_runWebSocket()
{
const operation =
retry.operation(this._options.retry || DEFAULT_RETRY_OPTIONS);
let wasConnected = false;
operation.attempt((currentAttempt) =>
{
if (this._closed)
{
operation.stop();
return;
}
logger.debug('_runWebSocket() [currentAttempt:%s]', currentAttempt);
this._ws = new W3CWebSocket(
this._url,
_execWithRetries(cqlQuery, dataParams, options, task) {
const retryDelay = Math.max(this.config.retryDelay || 100, 0);
const operation = retry.operation(this.config.retryOptions);
let consistency = options.consistency || this.poolConfig.consistencyLevel;
return new Promise((resolve, reject) => {
const executeRetryableCql = () => {
operation.attempt(async currentAttempt => {
options.consistency = consistency;
const queryRequestId = uuid.v4();
try {
const result = await this._timeQuery(queryRequestId, cqlQuery, dataParams, options, async options => {
const pool = await this._preparePool(options);
return task(pool, consistency);
});
return void resolve(result);
} catch (err) {
if (this._canRetryError(err)) {
if (operation.retry(err)) {
this.logger.warn(`priam.Cql: Retryable error condition encountered. Executing retry #${currentAttempt}...`, {
ConsumerGroupRecovery.prototype.getRetryTimeout = function (error) {
assert(error);
if (!this._timeouts) {
this._timeouts = retry.timeouts({
retries: this.options.retries,
factor: this.options.retryFactor,
minTimeout: this.options.retryMinTimeout
});
}
if (this._retryIndex == null || this.lastError == null || error.errorCode !== this.lastError.errorCode) {
this._retryIndex = 0;
}
var index = this._retryIndex++;
if (index >= this._timeouts.length) {
return false;
}
return this._timeouts[index];
};