fix: avoid JSON.stringify on circular response object in placeLimitBuy
When the CLOB client returns a failure response that contains a circular reference (e.g. axios/fetch internals), JSON.stringify throws "Maximum call stack size exceeded" which is caught and swallows the real error. Log only safe primitive fields (errorMsg, error, status) instead. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
78c66a9b1e
commit
9a5073dd20
@@ -241,7 +241,11 @@ async function placeLimitBuy(tokenId, shares, price, tickSize, negRisk) {
|
||||
OrderType.GTC,
|
||||
);
|
||||
if (!res?.success) {
|
||||
logger.error(`MakerMM: limit buy failed — response: ${JSON.stringify(res)}`);
|
||||
// JSON.stringify can throw "Maximum call stack size exceeded" if res
|
||||
// contains a circular reference (e.g. axios/fetch response object).
|
||||
// Log only safe primitive fields instead.
|
||||
const errDetail = res?.errorMsg || res?.error || res?.message || 'unknown';
|
||||
logger.error(`MakerMM: limit buy failed — response: {"error":"${errDetail}","status":${res?.status ?? 'n/a'}}`);
|
||||
return { success: false };
|
||||
}
|
||||
return { success: true, orderId: res.orderID };
|
||||
|
||||
Reference in New Issue
Block a user