A possible alternative would be only to check the status each time a new database connection is made, but that wouldn't catch the case where the server has been promoted.
Can we cache a false pg_is_in_recovery response and return that instead of querying the server?