Intermittent delays with IMAP Integration and gmail

I successfully connected my gmail account to home-assistant using the imap integration with the following configuration.yaml

sensor:
  - platform: imap
    name: mailhook
    server: imap.gmail.com
    port: 993
    username: [email protected]
    password: xxxxxxxxx [App Password]
    search: FROM <[email protected]>, SUBJECT <Work>

Everything works great, however I have noted intermittent delays from the mailhook entity.
Taking a look at the log files I note the warnings

01:00   Lost imap.gmail.com (will attempt to reconnect)
01:30   Lost imap.gmail.com (will attempt to reconnect) 
02:00   Lost imap.gmail.com (will attempt to reconnect)
......

this warning appears consistently every 30minutes. Adding a DEBUG logger for aioimaplib.aioimaplib shows home assistant immediate reconnecting to the gmail server after every disconnection. So I assume this is correct operation with each imap IDLE connection timing out after 30minutes according to the imap standard.
However I anecdotally note that an e-mail received within 0-~15minutes of a timeout is almost instantly received by the mailhook (within a few seconds), but an e-mail received ~15-30minutes after a timeout is not registered immediately. It is lost and the mailhook will only register on the next timeout when the IDLE connection is re-initialised. This results in ~10minute delay depending on when the e-mail is received versus the HA IDLE connection cycle.

There is no debug information in the HA log file that indicates a problem. Simply put the log file just shows that HA doesn’t receive an IDLE notification.

The g-mail android app, which I presume is also using IMAP IDLE see’s all mails instantaneously when connected to the same internet connection as HA. So I struggle to see that this is a server/network problem.

Can anyone replicate these results or have any idea’s what is going on here ?

Thanks go to Rami Mosleh for providing a work around. For some reason my gmail connection appears to be disconnecting after~15mins. Issue
The workaround is to create an automation with a time pattern trigger that repeats every 15mins, with the following yaml

alias: Refresh IMAP
description: Workaround to refresh IMAP connection every 15mins to re-establish the connection
trigger:
  - platform: time_pattern
    minutes: /15
condition: []
action:
  - service: homeassistant.update_entity
    data: {}
    target:
      entity_id: sensor.mailhook  #or the name of your IMAP sensor
mode: single

This re-initialises the IMAP connection every 15minutes.