Skip to content

Conversation

Ximik
Copy link

@Ximik Ximik commented Jun 17, 2025

Sends a HEAD request to the mempool transaction check server before attempting to check the actual transaction.
This prevents the client from getting stuck when the server is unavailable.

@buffrr
Copy link
Member

buffrr commented Jun 17, 2025

No need for a separate request. We should gracefully skip if POST fails.

@Ximik
Copy link
Author

Ximik commented Jun 17, 2025

POST can take too long to execute, because of either network issues or server being under load.
So, the idea is to first quickly check that the http is alive (with 1s timeout), and than do the real request with a huge timeout.
Reqwest reuses the connection by default, so the overhead of HEAD should be minimal.

@buffrr
Copy link
Member

buffrr commented Jun 17, 2025

Does this PR gracefully skip if POST fails?

POST can take too long to execute, because of either network issues or server being under load.

For network issues, HEAD would take the same time. If the server is under load then i still don't see the point of the HEAD request?

@Ximik
Copy link
Author

Ximik commented Jun 17, 2025

It skips even before the PR.

        let response = self.broadcast_client
            .post(endpoint)
            .body(tx_hex.to_string())
            .send()
            .await;

and it returns the Err only if response is correct and have an error message in it.

So, this PR is only adds timeouts.

The reason to have HEAD and POST separately is to have different timeouts

  1. Connection is slow - HEAD fails in 1s, no need to wait.
  2. Backend is slow - POST takes long, it is OK to wait for 30s.

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