@trpc/client 11.0.4 → 11.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -6,6 +6,10 @@ interface RetryLinkOptions<TInferrable extends InferrableClientTypes> {
|
|
|
6
6
|
* The retry function
|
|
7
7
|
*/
|
|
8
8
|
retry: (opts: RetryFnOptions<TInferrable>) => boolean;
|
|
9
|
+
/**
|
|
10
|
+
* The delay between retries in ms (defaults to 0)
|
|
11
|
+
*/
|
|
12
|
+
retryDelayMs?: (attempt: number) => number;
|
|
9
13
|
}
|
|
10
14
|
interface RetryFnOptions<TInferrable extends InferrableClientTypes> {
|
|
11
15
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"retryLink.d.ts","sourceRoot":"","sources":["../../src/links/retryLink.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,0CAA0C,CAAC;AAEtF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAEnD,UAAU,gBAAgB,CAAC,WAAW,SAAS,qBAAqB;IAClE;;OAEG;IACH,KAAK,EAAE,CAAC,IAAI,EAAE,cAAc,CAAC,WAAW,CAAC,KAAK,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"retryLink.d.ts","sourceRoot":"","sources":["../../src/links/retryLink.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,0CAA0C,CAAC;AAEtF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAEnD,UAAU,gBAAgB,CAAC,WAAW,SAAS,qBAAqB;IAClE;;OAEG;IACH,KAAK,EAAE,CAAC,IAAI,EAAE,cAAc,CAAC,WAAW,CAAC,KAAK,OAAO,CAAC;IACtD;;OAEG;IACH,YAAY,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,MAAM,CAAC;CAC5C;AAED,UAAU,cAAc,CAAC,WAAW,SAAS,qBAAqB;IAChE;;OAEG;IACH,EAAE,EAAE,SAAS,CAAC;IACd;;OAEG;IACH,KAAK,EAAE,eAAe,CAAC,WAAW,CAAC,CAAC;IACpC;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,WAAW,SAAS,qBAAqB,EACjE,IAAI,EAAE,gBAAgB,CAAC,WAAW,CAAC,GAClC,QAAQ,CAAC,WAAW,CAAC,CA4EvB"}
|
package/dist/links/retryLink.js
CHANGED
|
@@ -14,6 +14,7 @@ var inputWithTrackedEventId = require('../internals/inputWithTrackedEventId.js')
|
|
|
14
14
|
// initialized for request
|
|
15
15
|
return observable.observable((observer)=>{
|
|
16
16
|
let next$;
|
|
17
|
+
let callNextTimeout = undefined;
|
|
17
18
|
let lastEventId = undefined;
|
|
18
19
|
attempt(1);
|
|
19
20
|
function opWithLastEventId() {
|
|
@@ -35,11 +36,16 @@ var inputWithTrackedEventId = require('../internals/inputWithTrackedEventId.js')
|
|
|
35
36
|
attempts,
|
|
36
37
|
error
|
|
37
38
|
});
|
|
38
|
-
if (shouldRetry) {
|
|
39
|
-
attempt(attempts + 1);
|
|
40
|
-
} else {
|
|
39
|
+
if (!shouldRetry) {
|
|
41
40
|
observer.error(error);
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
const delayMs = opts.retryDelayMs?.(attempts) ?? 0;
|
|
44
|
+
if (delayMs <= 0) {
|
|
45
|
+
attempt(attempts + 1);
|
|
46
|
+
return;
|
|
42
47
|
}
|
|
48
|
+
callNextTimeout = setTimeout(()=>attempt(attempts + 1), delayMs);
|
|
43
49
|
},
|
|
44
50
|
next (envelope) {
|
|
45
51
|
//
|
|
@@ -56,6 +62,7 @@ var inputWithTrackedEventId = require('../internals/inputWithTrackedEventId.js')
|
|
|
56
62
|
}
|
|
57
63
|
return ()=>{
|
|
58
64
|
next$.unsubscribe();
|
|
65
|
+
clearTimeout(callNextTimeout);
|
|
59
66
|
};
|
|
60
67
|
});
|
|
61
68
|
};
|
package/dist/links/retryLink.mjs
CHANGED
|
@@ -12,6 +12,7 @@ import { inputWithTrackedEventId } from '../internals/inputWithTrackedEventId.mj
|
|
|
12
12
|
// initialized for request
|
|
13
13
|
return observable((observer)=>{
|
|
14
14
|
let next$;
|
|
15
|
+
let callNextTimeout = undefined;
|
|
15
16
|
let lastEventId = undefined;
|
|
16
17
|
attempt(1);
|
|
17
18
|
function opWithLastEventId() {
|
|
@@ -33,11 +34,16 @@ import { inputWithTrackedEventId } from '../internals/inputWithTrackedEventId.mj
|
|
|
33
34
|
attempts,
|
|
34
35
|
error
|
|
35
36
|
});
|
|
36
|
-
if (shouldRetry) {
|
|
37
|
-
attempt(attempts + 1);
|
|
38
|
-
} else {
|
|
37
|
+
if (!shouldRetry) {
|
|
39
38
|
observer.error(error);
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
const delayMs = opts.retryDelayMs?.(attempts) ?? 0;
|
|
42
|
+
if (delayMs <= 0) {
|
|
43
|
+
attempt(attempts + 1);
|
|
44
|
+
return;
|
|
40
45
|
}
|
|
46
|
+
callNextTimeout = setTimeout(()=>attempt(attempts + 1), delayMs);
|
|
41
47
|
},
|
|
42
48
|
next (envelope) {
|
|
43
49
|
//
|
|
@@ -54,6 +60,7 @@ import { inputWithTrackedEventId } from '../internals/inputWithTrackedEventId.mj
|
|
|
54
60
|
}
|
|
55
61
|
return ()=>{
|
|
56
62
|
next$.unsubscribe();
|
|
63
|
+
clearTimeout(callNextTimeout);
|
|
57
64
|
};
|
|
58
65
|
});
|
|
59
66
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trpc/client",
|
|
3
|
-
"version": "11.0
|
|
3
|
+
"version": "11.1.0",
|
|
4
4
|
"description": "The tRPC client library",
|
|
5
5
|
"author": "KATT",
|
|
6
6
|
"license": "MIT",
|
|
@@ -77,11 +77,11 @@
|
|
|
77
77
|
"!**/__tests__"
|
|
78
78
|
],
|
|
79
79
|
"peerDependencies": {
|
|
80
|
-
"@trpc/server": "11.0
|
|
80
|
+
"@trpc/server": "11.1.0",
|
|
81
81
|
"typescript": ">=5.7.2"
|
|
82
82
|
},
|
|
83
83
|
"devDependencies": {
|
|
84
|
-
"@trpc/server": "11.0
|
|
84
|
+
"@trpc/server": "11.1.0",
|
|
85
85
|
"@types/isomorphic-fetch": "^0.0.39",
|
|
86
86
|
"@types/node": "^22.13.5",
|
|
87
87
|
"dataloader": "^2.2.2",
|
|
@@ -101,5 +101,5 @@
|
|
|
101
101
|
"funding": [
|
|
102
102
|
"https://trpc.io/sponsor"
|
|
103
103
|
],
|
|
104
|
-
"gitHead": "
|
|
104
|
+
"gitHead": "0b93d77369ffbcaf70afa1052691bc643cf33a61"
|
|
105
105
|
}
|
package/src/links/retryLink.ts
CHANGED
|
@@ -12,6 +12,10 @@ interface RetryLinkOptions<TInferrable extends InferrableClientTypes> {
|
|
|
12
12
|
* The retry function
|
|
13
13
|
*/
|
|
14
14
|
retry: (opts: RetryFnOptions<TInferrable>) => boolean;
|
|
15
|
+
/**
|
|
16
|
+
* The delay between retries in ms (defaults to 0)
|
|
17
|
+
*/
|
|
18
|
+
retryDelayMs?: (attempt: number) => number;
|
|
15
19
|
}
|
|
16
20
|
|
|
17
21
|
interface RetryFnOptions<TInferrable extends InferrableClientTypes> {
|
|
@@ -42,6 +46,8 @@ export function retryLink<TInferrable extends InferrableClientTypes>(
|
|
|
42
46
|
// initialized for request
|
|
43
47
|
return observable((observer) => {
|
|
44
48
|
let next$: Unsubscribable;
|
|
49
|
+
let callNextTimeout: ReturnType<typeof setTimeout> | undefined =
|
|
50
|
+
undefined;
|
|
45
51
|
|
|
46
52
|
let lastEventId: string | undefined = undefined;
|
|
47
53
|
|
|
@@ -69,11 +75,20 @@ export function retryLink<TInferrable extends InferrableClientTypes>(
|
|
|
69
75
|
attempts,
|
|
70
76
|
error,
|
|
71
77
|
});
|
|
72
|
-
if (shouldRetry) {
|
|
73
|
-
attempt(attempts + 1);
|
|
74
|
-
} else {
|
|
78
|
+
if (!shouldRetry) {
|
|
75
79
|
observer.error(error);
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
const delayMs = opts.retryDelayMs?.(attempts) ?? 0;
|
|
83
|
+
|
|
84
|
+
if (delayMs <= 0) {
|
|
85
|
+
attempt(attempts + 1);
|
|
86
|
+
return;
|
|
76
87
|
}
|
|
88
|
+
callNextTimeout = setTimeout(
|
|
89
|
+
() => attempt(attempts + 1),
|
|
90
|
+
delayMs,
|
|
91
|
+
);
|
|
77
92
|
},
|
|
78
93
|
next(envelope) {
|
|
79
94
|
//
|
|
@@ -94,6 +109,7 @@ export function retryLink<TInferrable extends InferrableClientTypes>(
|
|
|
94
109
|
}
|
|
95
110
|
return () => {
|
|
96
111
|
next$.unsubscribe();
|
|
112
|
+
clearTimeout(callNextTimeout);
|
|
97
113
|
};
|
|
98
114
|
});
|
|
99
115
|
};
|