MCPcopy Index your code
hub / github.com/di-sukharev/opencommit / constructor

Method constructor

out/cli.cjs:58054–58112  ·  view source on GitHub ↗
(opts, handlers)

Source from the content-addressed store, hash-verified

58052 var { RequestRetryError } = require_errors3();
58053 var { isDisturbed, parseHeaders, parseRangeHeader } = require_util2();
58054 function calculateRetryAfterHeader(retryAfter) {
58055 const current = Date.now();
58056 const diff = new Date(retryAfter).getTime() - current;
58057 return diff;
58058 }
58059 var RetryHandler = class _RetryHandler {
58060 constructor(opts, handlers) {
58061 const { retryOptions, ...dispatchOpts } = opts;
58062 const {
58063 // Retry scoped
58064 retry: retryFn,
58065 maxRetries,
58066 maxTimeout,
58067 minTimeout,
58068 timeoutFactor,
58069 // Response scoped
58070 methods,
58071 errorCodes,
58072 retryAfter,
58073 statusCodes
58074 } = retryOptions ?? {};
58075 this.dispatch = handlers.dispatch;
58076 this.handler = handlers.handler;
58077 this.opts = dispatchOpts;
58078 this.abort = null;
58079 this.aborted = false;
58080 this.retryOpts = {
58081 retry: retryFn ?? _RetryHandler[kRetryHandlerDefaultRetry],
58082 retryAfter: retryAfter ?? true,
58083 maxTimeout: maxTimeout ?? 30 * 1e3,
58084 // 30s,
58085 timeout: minTimeout ?? 500,
58086 // .5s
58087 timeoutFactor: timeoutFactor ?? 2,
58088 maxRetries: maxRetries ?? 5,
58089 // What errors we should retry
58090 methods: methods ?? ["GET", "HEAD", "OPTIONS", "PUT", "DELETE", "TRACE"],
58091 // Indicates which errors to retry
58092 statusCodes: statusCodes ?? [500, 502, 503, 504, 429],
58093 // List of errors to retry
58094 errorCodes: errorCodes ?? [
58095 "ECONNRESET",
58096 "ECONNREFUSED",
58097 "ENOTFOUND",
58098 "ENETDOWN",
58099 "ENETUNREACH",
58100 "EHOSTDOWN",
58101 "EHOSTUNREACH",
58102 "EPIPE"
58103 ]
58104 };
58105 this.retryCount = 0;
58106 this.start = 0;
58107 this.end = null;
58108 this.etag = null;
58109 this.resume = null;
58110 this.handler.onConnect((reason) => {
58111 this.aborted = true;

Callers

nothing calls this directly

Calls 2

onConnectMethod · 0.45
abortMethod · 0.45

Tested by

no test coverage detected