@remcp/remcp 0.2.83 → 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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remcp/remcp",
3
- "version": "0.2.83",
3
+ "version": "0.2.84",
4
4
  "description": "ReMCP device client: pair a computer with ReMCP and run the outbound-only agent that hosts the local MCP runtime.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -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 fetch(`${server}/oauth/device_authorization`, {
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 fetch(`${server}/oauth/token`, {
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({