Skip to content

Conversation

@arcoraven
Copy link
Contributor

@arcoraven arcoraven commented Nov 8, 2024

PR-Codex overview

This PR focuses on improving error handling in the transaction processing logic and refining the retry mechanism for failed transactions.

Detailed summary

  • Updated error handling in withErrorHandler to support string errors.
  • Simplified the error response structure.
  • Enhanced the transaction retry logic in sendTransactionWorker by omitting unnecessary fields.
  • Improved error message handling for errored transactions.

✨ Ask PR-Codex anything about this PR by commenting with /codex {your question}

server.setErrorHandler(
(error: Error | CustomError | ZodError, request, reply) => {
(error: string | Error | CustomError | ZodError, request, reply) => {
if (typeof error === "string") {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently a thrown string is not logged.
While we shouldn't throw raw strings, this update at least prints the string value.

transaction = {
...{
...transaction,
nonce: undefined,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was the bug. By setting values to undefined, they were explicitly set to undefined in the type. This is unexpected because the typing implies undefined is not a valid value, which leads to weird edge cases like the code not handling undefined values.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix here was to flatten this code to override certain fields only.

Note:

  • nonce doesn't need to be unset since we're calling _sendTransaction() again which generates a new nonce as expected.
  • gas fees don't need to be unset since overrides were moved to a separate nested object.

Comment on lines +247 to +254
const errorMessage = wrapError(error, "Bundler").message;
const erroredTransaction: ErroredTransaction = {
...queuedTransaction,
status: "errored",
errorMessage: wrapError(error, "Bundler").message,
} satisfies ErroredTransaction;
errorMessage,
};
job.log(`Failed to populate transaction: ${errorMessage}`);
return erroredTransaction;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated fix, I previously removed the job.log() here but now I want it back. It's important for us to know if an error was thrown during simulation/estimation or when sending the tx.

@arcoraven arcoraven merged commit a121730 into main Nov 8, 2024
4 checks passed
@arcoraven arcoraven deleted the ph/fixRetryTransactionUndefined branch November 8, 2024 04:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants