Lint all network sync calls

Just stumbled on a pretty bad bug. We have an async application. And unfortunately, the DNS resolution in one place was done synchronously by to_socket_addrs.

It all worked well when DNS was resolved fast, and it started to exhibit very unpleasant behavior when DNS began to act up.

BTW. The documentation is quite clear: "Note that this function may block the current thread while resolution is performed.". However, it took a while to figure out what was going on.

I am worried that

  • It's too easy to introduce in another place a call to_socket_addrs
  • There could be other sync network calls that I should be aware of.

So, the question is. Do you know any tools or configurations to check for things like that? (My guess is I am not the first "lucky" person to stumble on these problems).

It sounds like you might be looking for Clippy's disallowed_method and disallowed_type lints.

From there, just make sure you run clippy as part of your CI. This is what I include in the GitHub Actions for every project I work on, nowadays:


This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.