Skip to content

Commit f663e7a

Browse files
authored
Fix ethers error messages sanitization (#294)
* Sanitize ethers error messages * Add more context to logs * Update sanitizeError function
1 parent 12bd571 commit f663e7a

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

src/update-feeds-loops/pending-transaction-info.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,11 @@ export const updatePendingTransactionsInfo = (
5757
: 1;
5858
const firstUpdatableTimestamp = pendingTransactionInfo?.firstUpdatableTimestamp ?? currentTimestamp;
5959
const newPendingTransactionInfo = { consecutivelyUpdatableCount, firstUpdatableTimestamp };
60-
logger.info('Updating pending transaction info.', newPendingTransactionInfo);
60+
logger.info('Updating pending transaction info.', {
61+
...newPendingTransactionInfo,
62+
dapiName: decodedDapiName,
63+
dataFeedId,
64+
});
6165
setPendingTransactionInfo(chainId, providerName, sponsorWalletAddress, newPendingTransactionInfo);
6266
}
6367
if (!isFeedUpdatable && pendingTransactionInfo) {

src/update-feeds-loops/submit-transactions.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,10 +166,13 @@ export const submitTransaction = async (
166166
return null;
167167
} else if (ethersError.code === 'INSUFFICIENT_FUNDS') {
168168
// This should never happen and monitoring should warn even before Airseeker comes to this point.
169-
logger.error(`Failed to submit the transaction because of insufficient funds.`, ethersError);
169+
logger.error(
170+
`Failed to submit the transaction because of insufficient funds.`,
171+
sanitizeEthersError(ethersError)
172+
);
170173
return null;
171174
} else {
172-
logger.warn(`Failed to submit the update transaction.`, ethersError);
175+
logger.warn(`Failed to submit the update transaction.`, sanitizeEthersError(ethersError));
173176
return null;
174177
}
175178
}

src/utils.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,12 @@ export const sanitizeEthersError = (error: Error) => {
9191

9292
// We don't care about the stack trace, nor error name - just the code and the message. According to the ethers
9393
// sources, the short message should always be defined.
94-
return new SanitizedErrorsError(ethersError.code, ethersError.shortMessage);
94+
const sanitizedError = new SanitizedErrorsError(ethersError.code, ethersError.shortMessage);
95+
// NOTE: We don't need the stack trace, because the errors are usually easy to find by the developer message and the
96+
// stack can be traced manually. This reduces the risk of the stack trace being too large and "exploding" the log
97+
// size.
98+
delete sanitizedError.stack;
99+
return sanitizedError;
95100
};
96101

97102
export const generateRandomId = () => randomBytes(32).toString('hex');

0 commit comments

Comments
 (0)