@mentra/cloud-client 3.3.0-dev.838 → 3.3.0-dev.840

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.
Files changed (2) hide show
  1. package/package.json +2 -2
  2. package/src/http.ts +21 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mentra/cloud-client",
3
- "version": "3.3.0-dev.838",
3
+ "version": "3.3.0-dev.840",
4
4
  "type": "module",
5
5
  "main": "./src/index.ts",
6
6
  "exports": {
@@ -12,7 +12,7 @@
12
12
  "test": "bun test"
13
13
  },
14
14
  "dependencies": {
15
- "@mentra/cloud-protocol": "3.3.0-dev.838",
15
+ "@mentra/cloud-protocol": "3.3.0-dev.840",
16
16
  "tweetnacl": "^1.0.3"
17
17
  },
18
18
  "devDependencies": {
package/src/http.ts CHANGED
@@ -69,6 +69,25 @@ const MAX_RETRIES = 2;
69
69
  /** Base backoff in milliseconds; doubles per attempt (250, 500, ...). */
70
70
  const RETRY_BASE_MS = 250;
71
71
 
72
+ /** Recognize only fixed native categories; never log an exception message, stack or arbitrary code. */
73
+ function nativeFailureCode(error: unknown): string | undefined {
74
+ if (typeof error !== "object" || error === null || !("code" in error)) return undefined;
75
+ const code = error.code;
76
+ return typeof code === "string" &&
77
+ [
78
+ "E_NATIVE_HTTP_DNS",
79
+ "E_NATIVE_HTTP_CONNECT",
80
+ "E_NATIVE_HTTP_TIMEOUT",
81
+ "E_NATIVE_HTTP_TLS",
82
+ "E_NATIVE_HTTP_SOCKET",
83
+ "E_NATIVE_HTTP_INTERRUPTED",
84
+ "E_NATIVE_HTTP_IO",
85
+ "E_NATIVE_HTTP_OTHER",
86
+ ].includes(code)
87
+ ? code
88
+ : undefined;
89
+ }
90
+
72
91
  /**
73
92
  * Join a base URL and a path without producing a double slash or dropping one.
74
93
  *
@@ -186,7 +205,8 @@ export function createHttpClient(deps: CreateHttpClientDeps): HttpClient {
186
205
  throwIfAborted(signal);
187
206
  if (isAbortError(error)) throw error;
188
207
  // Transient network failure: let the loop retry.
189
- logger.warn("http network error", { method, path, attempt });
208
+ const nativeCode = nativeFailureCode(error);
209
+ logger.warn("http network error", { method, path, attempt, ...(nativeCode ? { nativeCode } : {}) });
190
210
  continue;
191
211
  }
192
212