pi-antigravity-rotator 1.3.5 → 1.3.6
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/proxy.ts +22 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-antigravity-rotator",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.6",
|
|
4
4
|
"description": "Multi-account rotation proxy for Google Antigravity with per-model routing, real-time quota tracking, and infringement detection",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
package/src/proxy.ts
CHANGED
|
@@ -86,6 +86,23 @@ function capCooldown(ms: number): number {
|
|
|
86
86
|
return Math.min(ms, MAX_COOLDOWN_MS);
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
+
function formatError(err: unknown): string {
|
|
90
|
+
if (!(err instanceof Error)) return String(err);
|
|
91
|
+
const cause = err.cause;
|
|
92
|
+
if (cause && typeof cause === "object") {
|
|
93
|
+
const code = "code" in cause ? String(cause.code) : null;
|
|
94
|
+
const message = "message" in cause ? String(cause.message) : null;
|
|
95
|
+
if (code || message) {
|
|
96
|
+
return `${err.name}: ${err.message} (${[code, message].filter(Boolean).join(": ")})`;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return `${err.name}: ${err.message}`;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function isFetchTransportError(err: unknown): boolean {
|
|
103
|
+
return err instanceof TypeError && err.message === "fetch failed";
|
|
104
|
+
}
|
|
105
|
+
|
|
89
106
|
/**
|
|
90
107
|
* Read the full request body from an IncomingMessage.
|
|
91
108
|
*/
|
|
@@ -319,8 +336,11 @@ async function handleProxyRequest(
|
|
|
319
336
|
}
|
|
320
337
|
return;
|
|
321
338
|
} catch (err) {
|
|
322
|
-
|
|
323
|
-
|
|
339
|
+
const formattedError = formatError(err);
|
|
340
|
+
proxyLog(`[${label}] Request failed: ${formattedError}`, isFetchTransportError(err) ? "warn" : "error");
|
|
341
|
+
if (!isFetchTransportError(err)) {
|
|
342
|
+
rotator.markError(account, formattedError);
|
|
343
|
+
}
|
|
324
344
|
if (res.headersSent) {
|
|
325
345
|
res.end();
|
|
326
346
|
return;
|