Add max duration to avoid exceeding timeout/endless loop.