@urql/exchange-retry
Advanced tools
Comparing version 0.3.0 to 0.3.1
# Changelog | ||
## 0.3.1 | ||
### Patch Changes | ||
- ⚠️ Fix operations sometimes not being executed after a retry is supposed to be triggered, due to a `setTimeout` reordering issue when the timer isn't as predictable as it should be, by [@kitten](https://github.com/kitten) (See [#2124](https://github.com/FormidableLabs/urql/pull/2124)) | ||
## 0.3.0 | ||
@@ -4,0 +10,0 @@ |
@@ -25,5 +25,5 @@ var r = require("wonka"); | ||
var u = t.maxNumberAttempts || 2; | ||
var s = t.randomDelay || !0; | ||
var c = t.randomDelay || !0; | ||
return function(t) { | ||
var c = t.forward; | ||
var s = t.forward; | ||
var y = t.dispatchDebug; | ||
@@ -38,6 +38,6 @@ return function(t) { | ||
var n = t.context; | ||
var c = (n.retryCount || 0) + 1; | ||
var s = (n.retryCount || 0) + 1; | ||
var p = n.retryDelay || o; | ||
var f = Math.random() + 1.5; | ||
if (s && p * f < i) { | ||
if (c && p * f < i) { | ||
p *= f; | ||
@@ -50,12 +50,14 @@ } | ||
type: "retryAttempt", | ||
message: "The operation has failed and a retry has been triggered (" + c + " / " + u + ")", | ||
message: "The operation has failed and a retry has been triggered (" + s + " / " + u + ")", | ||
operation: t, | ||
data: { | ||
retryCount: c | ||
retryCount: s | ||
}, | ||
source: "retryExchange" | ||
}); | ||
return r.takeUntil(d)(r.delay(p)(r.fromValue(e.makeOperation(t.kind, t, _extends({}, t.context, { | ||
return r.takeUntil(d)(r.debounce((function() { | ||
return p; | ||
}))(r.fromValue(e.makeOperation(t.kind, t, _extends({}, t.context, { | ||
retryDelay: p, | ||
retryCount: c | ||
retryCount: s | ||
}))))); | ||
@@ -82,3 +84,3 @@ }))(f); | ||
return !0; | ||
}))(r.share(c(r.merge([ v, h ])))); | ||
}))(r.share(s(r.merge([ v, h ])))); | ||
}; | ||
@@ -85,0 +87,0 @@ }; |
@@ -1,2 +0,2 @@ | ||
var r=require("wonka"),e=require("@urql/core");function t(){return(t=Object.assign||function(r){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(r[n]=t[n])}return r}).apply(this,arguments)}exports.retryExchange=function(n){var o=n.retryIf,a=n.retryWith,i=n.initialDelayMs||1e3,u=n.maxDelayMs||15e3,y=n.maxNumberAttempts||2,c=n.randomDelay||!0;return function(n){var f=n.forward;return function(n){var l=r.share(n),p=r.makeSubject(),m=p.source,s=p.next,k=r.mergeMap((function(n){var o=n.key,a=n.context,y=(a.retryCount||0)+1,f=a.retryDelay||i,p=Math.random()+1.5;c&&f*p<u&&(f*=p);var m=r.filter((function(r){return("query"===r.kind||"teardown"===r.kind)&&r.key===o}))(l);return r.takeUntil(m)(r.delay(f)(r.fromValue(e.makeOperation(n.kind,n,t({},n.context,{retryDelay:f,retryCount:y})))))}))(m);return r.filter((function(r){if(!r.error||!(o?o(r.error,r.operation):a||r.error.networkError))return!0;if(!((r.operation.context.retryCount||0)>=y-1)){var e=a?a(r.error,r.operation):r.operation;return!e||(s(e),!1)}return!0}))(r.share(f(r.merge([l,k]))))}}}; | ||
var r=require("wonka"),e=require("@urql/core");function t(){return(t=Object.assign||function(r){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(r[n]=t[n])}return r}).apply(this,arguments)}exports.retryExchange=function(n){var o=n.retryIf,a=n.retryWith,u=n.initialDelayMs||1e3,i=n.maxDelayMs||15e3,c=n.maxNumberAttempts||2,y=n.randomDelay||!0;return function(n){var f=n.forward;return function(n){var l=r.share(n),p=r.makeSubject(),m=p.source,s=p.next,k=r.mergeMap((function(n){var o=n.key,a=n.context,c=(a.retryCount||0)+1,f=a.retryDelay||u,p=Math.random()+1.5;y&&f*p<i&&(f*=p);var m=r.filter((function(r){return("query"===r.kind||"teardown"===r.kind)&&r.key===o}))(l);return r.takeUntil(m)(r.debounce((function(){return f}))(r.fromValue(e.makeOperation(n.kind,n,t({},n.context,{retryDelay:f,retryCount:c})))))}))(m);return r.filter((function(r){if(!r.error||!(o?o(r.error,r.operation):a||r.error.networkError))return!0;if(!((r.operation.context.retryCount||0)>=c-1)){var e=a?a(r.error,r.operation):r.operation;return!e||(s(e),!1)}return!0}))(r.share(f(r.merge([l,k]))))}}}; | ||
//# sourceMappingURL=urql-exchange-retry.min.js.map |
{ | ||
"name": "@urql/exchange-retry", | ||
"version": "0.3.0", | ||
"version": "0.3.1", | ||
"description": "An exchange for operation retry support in urql", | ||
@@ -5,0 +5,0 @@ "sideEffects": false, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
40164
190
0