Replays a request when a network error occurs
DO NOT use this module if you are piping
If you are listening to
data events to buffer, beware that you must reset everything when a
This is why
pipping is not supported.
$ npm install request-replay
var fs = require'fs';var request = require'request';var replay = require'request-replay';// Note that the options argument is optional// Accepts the same options the retry module does and an additional// errorCodes array that default to ['EADDRINFO', 'ETIMEDOUT', 'ECONNRESET', 'ESOCKETTIMEDOUT']replayrequest''// Do thingsretries: 10factor: 3on'replay'// "replay" is an object that contains some useful informationconsole.log'request failed: ' + replay.errorcode + ' ' + replay.errormessage;console.log'replay nr: #' + replaynumber;console.log'will retry in: ' + replaydelay + 'ms'
Note that the default retry options are modified to be more appropriate for requests:
retries: The maximum amount of times to retry the operation. Default is
factor: The exponential factor to use. Default is
minTimeout: The amount of time before starting the first retry. Default is
maxTimeout: The maximum amount of time between two retries. Default is
randomize: Randomizes the timeouts by multiplying with a factor between
2. Default is
Released under the MIT License.