fix: patch CLOB client JSON.stringify to handle circular proxy agent
The CLOB client errorHandling function does JSON.stringify on err.response.config which includes httpsAgent (HttpsProxyAgent with circular references). Inject a safe serializer that strips agent properties before serializing. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
0886938694
commit
e9e5d66ac9
@@ -66,6 +66,11 @@ axios_1.default.interceptors.request.use(function(cfg) {
|
|||||||
}
|
}
|
||||||
return cfg;
|
return cfg;
|
||||||
});
|
});
|
||||||
|
// Safe JSON.stringify that strips circular agent refs
|
||||||
|
const _safeStringify = (obj) => JSON.stringify(obj, (key, val) => {
|
||||||
|
if (key === 'httpsAgent' || key === 'httpAgent' || key === 'agent') return undefined;
|
||||||
|
return val;
|
||||||
|
});
|
||||||
// ── End proxy patch ────────────────────────────────────────────────────────
|
// ── End proxy patch ────────────────────────────────────────────────────────
|
||||||
`;
|
`;
|
||||||
|
|
||||||
@@ -95,5 +100,13 @@ if (!injected) {
|
|||||||
process.exit(0);
|
process.exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ── Patch errorHandling to avoid circular JSON serialization ────────────────
|
||||||
|
// The CLOB client does JSON.stringify(err.response.config) which includes
|
||||||
|
// httpsAgent with circular references. Replace with safe serializer.
|
||||||
|
const jsonCount = (code.match(/JSON\.stringify\(/g) || []).length;
|
||||||
|
code = code.replace(/JSON\.stringify\(/g, '_safeStringify(');
|
||||||
|
const patchedCount = (code.match(/_safeStringify\(/g) || []).length;
|
||||||
|
console.log(`[patch] Replaced ${jsonCount} JSON.stringify calls with safe serializer`);
|
||||||
|
|
||||||
fs.writeFileSync(TARGET, code, 'utf8');
|
fs.writeFileSync(TARGET, code, 'utf8');
|
||||||
console.log('[patch] @polymarket/clob-client patched with proxy support ✅');
|
console.log('[patch] @polymarket/clob-client patched with proxy support ✅');
|
||||||
|
|||||||
Reference in New Issue
Block a user