@remcp/remcp 0.2.82 → 0.2.84
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.
- package/package.json +1 -1
- package/src/cli/connect.mjs +17 -2
package/package.json
CHANGED
package/src/cli/connect.mjs
CHANGED
|
@@ -29,11 +29,26 @@ export function openInBrowser(url) {
|
|
|
29
29
|
} catch {}
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
+
const TRANSIENT_FETCH_RETRY_DELAY_MS = 150;
|
|
33
|
+
|
|
34
|
+
async function fetchWithTransientRetry(url, options) {
|
|
35
|
+
try {
|
|
36
|
+
return await fetch(url, options);
|
|
37
|
+
} catch (error) {
|
|
38
|
+
// Node/undici reports transport failures (connection reset/refused, socket close, timeout)
|
|
39
|
+
// as TypeError("fetch failed"). HTTP responses never enter this branch, so auth/server
|
|
40
|
+
// rejections remain fail-closed and are not retried here.
|
|
41
|
+
if (!(error instanceof TypeError)) throw error;
|
|
42
|
+
await sleep(TRANSIENT_FETCH_RETRY_DELAY_MS);
|
|
43
|
+
return fetch(url, options);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
32
47
|
// Device authorization (RFC 8628): the computer asks for a code, the person approves it in the
|
|
33
48
|
// browser while signed in, and this process collects the credential by polling. The device never
|
|
34
49
|
// sees a browser session or an account password.
|
|
35
50
|
export async function pairWithDeviceCode(server, flags) {
|
|
36
|
-
const authorization = await
|
|
51
|
+
const authorization = await fetchWithTransientRetry(`${server}/oauth/device_authorization`, {
|
|
37
52
|
method: 'POST',
|
|
38
53
|
headers: { 'content-type': 'application/json' },
|
|
39
54
|
body: JSON.stringify({
|
|
@@ -56,7 +71,7 @@ export async function pairWithDeviceCode(server, flags) {
|
|
|
56
71
|
const intervalMs = Math.max(1, Number(grant.interval) || 5) * 1000;
|
|
57
72
|
while (Date.now() < deadline) {
|
|
58
73
|
await sleep(intervalMs);
|
|
59
|
-
const response = await
|
|
74
|
+
const response = await fetchWithTransientRetry(`${server}/oauth/token`, {
|
|
60
75
|
method: 'POST',
|
|
61
76
|
headers: { 'content-type': 'application/x-www-form-urlencoded' },
|
|
62
77
|
body: new URLSearchParams({
|