avoid returning objects with circular buffers
This commit is contained in:
parent
fe293d91ee
commit
82806b6fcb
@ -87,11 +87,30 @@ function hasExpectedAssetData(
|
|||||||
|
|
||||||
function convertIfAxiosError(error: any): Error | object /* axios' .d.ts has AxiosError.toJSON() returning object */ {
|
function convertIfAxiosError(error: any): Error | object /* axios' .d.ts has AxiosError.toJSON() returning object */ {
|
||||||
if (error.hasOwnProperty('isAxiosError') && error.isAxiosError && error.hasOwnProperty('toJSON')) {
|
if (error.hasOwnProperty('isAxiosError') && error.isAxiosError && error.hasOwnProperty('toJSON')) {
|
||||||
return error.toJSON();
|
const { message, name, config } = error;
|
||||||
} else {
|
const { headers, timeout, httpsAgent } = config;
|
||||||
|
const { keepAlive, keepAliveMsecs, sockets } = httpsAgent;
|
||||||
|
|
||||||
|
const socketCounts: { [key: string]: number } = {};
|
||||||
|
for (const socket of Object.keys(sockets)) {
|
||||||
|
socketCounts[socket] = sockets[socket].length;
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
message: error.message,
|
message,
|
||||||
|
name,
|
||||||
|
config: {
|
||||||
|
headers,
|
||||||
|
timeout,
|
||||||
|
httpsAgent: {
|
||||||
|
keepAlive,
|
||||||
|
keepAliveMsecs,
|
||||||
|
socketCounts,
|
||||||
|
},
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
} else {
|
||||||
|
return error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user