New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@mimik/request-retry

Package Overview
Dependencies
Maintainers
5
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mimik/request-retry

Request retry wrapping axios

latest
Source
npmnpm
Version
4.0.12
Version published
Maintainers
5
Created
Source

request-retry

Example

import { rpRetry } from '@mimik/request-retry';
// or
import rp from '@mimik/request-retry';

request-retry~rpRetry(options) ⇒ Promise.<*>

Make a request with retries.

Kind: inner method of request-retry
Returns: Promise.<*> - A bluebird promise (supports cancellation).
Category: async
Throws:

  • Error An error produced by getRichError, wrapping an Axios error or a TimeoutError.

The default retryStrategy is:

defaultRetry = (...args) => {
  const { statusCode } = args[1]; // err
  // Retry on 5xx and 429. If there is no statusCode, retry unless it's an "Invalid URI" error.
  return (statusCode && (Math.floor(statusCode / 100) === 5 || statusCode === 429))
         || (!statusCode && !args[1].message.includes('Invalid URI'));
};

If not already set, the User-Agent header is set to: mimik-{serverType}/{serverVersion}/{serverId} {architecture} {node}.

To ease migration from request-promise, the following adjustments are applied to options:

  • uri takes precedence over url.
  • If json is an object, body takes precedence over json; both are mapped to Axios data.
  • qs is mapped to Axios params.

Requires: module:@mimik/sumologic-winston-logger, module:@mimik/response-helper
Fulfil: object - The Axios response when resolveWithFullResponse is true; otherwise response.data.

ParamTypeDefaultDescription
optionsobjectOptions for the request (similar to axios). The validateStatus option is disabled: an error is thrown for status codes outside [200, 300). An additional option, resolveWithFullResponse, controls the return shape: when true, the full Axios response object is returned; when false or omitted, only response.data is returned.
[options.retry]objectRetry configuration.
[options.retry.retries]number2Maximum number of retries, independent of the retryStrategy. If the value is < 0, it is set to 0; if > 15, it is set to 15.
[options.retry.delay]number1000Delay between retries in milliseconds when no delayStrategy is provided. If the value is < 20, it is set to 20; if > 30000, it is set to 30000.
[options.retry.delayStrategy]functionA function that returns the delay (in milliseconds) to wait before the next retry. Signature: (nbRetry, err, options, correlationId). Must return a number > 0 and < 30000; otherwise delay is used.
[options.retry.retryStrategy]functionA function that decides whether to retry. Signature: (nbRetry, err, options, correlationId). Must return a boolean; otherwise it is ignored.
[options.retry.timeout]number50Request timeout (in seconds) applied to the initial request and all retries. If reached, a TimeoutError is thrown. Values < 10 are set to 10; values > 120 are set to 120.
[options.retry.logLevel]objectControls logging behavior. When omitted, requests and responses are logged at info with full details, and errors at warn. When provided but incomplete, only the provided keys are active; missing keys disable that logging. Non-object values are ignored and defaults apply.
[options.retry.logLevel.response]stringLog level for responses. Invalid values fall back to silly.
[options.retry.logLevel.error]stringLog level for errors. Invalid values fall back to silly.
[options.retry.logLevel.request]stringLog level for requests. Invalid values fall back to silly.
[options.retry.logLevel.responseDetails]string"'type'"Detail level for the response: count, type, or full. Invalid values fall back to type. When logLevel is omitted entirely, the default is full.
[options.retry.logLevel.responseName]string"'response'"Label associated with the response. Non-string or empty values fall back to response.
[options.metrics]objectMetrics configuration.
[options.metrics.HTTPRequestDuration]functionA prom-client metric function to measure request duration.
[options.metrics.url]stringOptional URL label for the metric. If omitted, the request URL is used.

Keywords

mimik

FAQs

Package last updated on 22 Mar 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts