Company
Date Published
Author
Kevin Burke
Word count
1597
Language
English
Hacker News points
None

Summary

You can write an HTTP client to handle various types of failures in production-ready systems. Connection errors can be handled by setting a timeout on the connection request and retrying it if it fails, while closed connections should be treated as 500-level errors. Third-party servers taking too long to respond can be mitigated by assigning a timeout value to external requests and executing fallback logic if the request times out. HTTP level errors, such as non-200 level responses, are generally safe to retry if the request is idempotent. A production-ready client needs to handle these failures properly, and you can test your client using libraries that simulate various types of network failures.