thegreenwebfoundation / greencheck-api

The green web foundation API
https://www.thegreenwebfoundation.org/
Apache License 2.0
9 stars 3 forks source link

Handle timeouts more gracefully in the API when doing DNS looksups #44

Closed mrchrisadams closed 1 month ago

mrchrisadams commented 4 years ago

At present, when you use the multi domain API, if a domain is taking a long time to resolve, we make a use wait for tens of seconds, before eventually serving a 500 error.

I saw this when debugging requests made for the new sitespeed plugin, and was eventually able to trace it down doing a multi-look-up with this API url:

http://api.thegreenwebfoundation.org/v2/greencheckmulti/[%22srv-2020-02-13-22.pixel.parsely.com%22]

What happens now

Right now, when look up and what I assume is a DNS look takes a very long time, we wait for nearly a minute, and then we serve a 500 page as html.

What I'd expect to happen

Because we're relying on a bunch of DNS lookups in a multidomain API call, and each could take an undefined amount of time, I would expect a response listing: