4 ms·
Or why your software should never use arbitrary timeouts. Without the 30s timeout this bug would have been caught and fixed before release.
by jacobgorm 1y ago
Or why your software should never use arbitrary timeouts. Without the 30s timeout this bug would have been caught and fixed before release.
- berkes 1y agoIn one project, we had an ENV var (a few actually) for timeouts of network requests. Most places would raise an exception if they hit this timeout. In test and CI we had this set to a very low number. In acceptance (manual testing, smoke testing) to a very high number. This was useful because it showed three things: - Network- and services- configuration bugs, would immediately give a crash and thus failing test. E.g. firewalls, wrong hosts, broken URIs etc. - Slow services would cause flickering tests. Almost always a sign that some service/configuration/component had performance problems or was misconfigured itself. Quick fix would be to increase the timeout, but re-thinking the service - e.g. replace with a mock if we couldn't control it, or fixing its performance issues, the proper- and often not that hard- fix. Or re-thinking the use of the service, e.g. by pushing it to async or a job queue or such another fix. - Stakeholders going through the smoke-test and acceptance test would inevitably report "it's really slow" showing the same issues as above but in a different context and with "real" services like some external PSP, or SMTP. It was really a very small change: just some wrappers around http-calls and other network calls, in which this config was used, next to a hard rule to never use "native" clients/libs in the code but always our abstraction. This then turned out to offer so much more benefits than just this timeout: error reporting, debugging, decoupling. It wasn't javascript (Ruby, some Python, some Typescript) but in JS it would be as easy as `function fooFetch(resource, options) { return fetch(resource, options) }` from day one, then slowly extended and improved with said logging, reporting, defaults etc. I've since always introduced such "anti-corruption" layers (facades, proxy, ports/adapters) very early on, because once you have "requests.get("http://example.com/foo/bar http://example.com/foo/bar")' all throughout your python code, there's no way to ever migrate away from "requests" if (when!) it gets deprecated, or to add said timeout throughout the code. It's really a tiny task to add my own file/module that simply imports "requests" and then calls it on day one, and then use that instead.
- bornfreddy 1y agoI wonder what happens if some operation genuinly takes more than 30s to complete in sone cases? I'm sure the system handles it gracefully. /s