nextcloud / mail

💌 Mail app for Nextcloud
https://apps.nextcloud.com/apps/mail
GNU Affero General Public License v3.0
818 stars 255 forks source link

Background sync SSL errors not caught #8363

Open ChristophWurst opened 1 year ago

ChristophWurst commented 1 year ago

Steps to reproduce

  1. Have an account with faulty SSL
  2. Run a background sync

Expected behavior

Cron mail sync failed for account 123

Actual behavior

I can't tell which account caused the error:

{
  "reqId": "ygueNZNt088KydR56gGp",
  "level": 3,
  "time": "April 12, 2023 07:36:19",
  "remoteAddr": "",
  "user": "--",
  "app": "PHP",
  "method": "",
  "url": "--",
  "message": "fgets(): SSL: Connection reset by peer at /var/www/html/apps/mail/vendor/bytestream/horde-imap-client/lib/Horde/Imap/Client/Socket/Connection/Socket.php#156",
  "userAgent": "--",
  "version": "25.0.4.1",
  "exception": {
    "Exception": "Error",
    "Message": "fgets(): SSL: Connection reset by peer at /var/www/html/apps/mail/vendor/bytestream/horde-imap-client/lib/Horde/Imap/Client/Socket/Connection/Socket.php#156",
    "Code": 0,
    "Trace": [
      {
        "function": "onError",
        "class": "OC\\Log\\ErrorHandler",
        "type": "::"
      },
      {
        "file": "/var/www/html/apps/mail/vendor/bytestream/horde-imap-client/lib/Horde/Imap/Client/Socket/Connection/Socket.php",
        "line": 156,
        "function": "fgets"
      },
      {
        "file": "/var/www/html/apps/mail/vendor/bytestream/horde-imap-client/lib/Horde/Imap/Client/Socket.php",
        "line": 4541,
        "function": "read",
        "class": "Horde_Imap_Client_Socket_Connection_Socket",
        "type": "->"
      },
      {
        "file": "/var/www/html/apps/mail/vendor/bytestream/horde-imap-client/lib/Horde/Imap/Client/Socket.php",
        "line": 4313,
        "function": "_getLine",
        "class": "Horde_Imap_Client_Socket",
        "type": "->"
      },
      {
        "file": "/var/www/html/apps/mail/vendor/bytestream/horde-imap-client/lib/Horde/Imap/Client/Socket.php",
        "line": 4241,
        "function": "_sendCmdChunk",
        "class": "Horde_Imap_Client_Socket",
        "type": "->"
      },
      {
        "file": "/var/www/html/apps/mail/vendor/bytestream/horde-imap-client/lib/Horde/Imap/Client/Socket.php",
        "line": 967,
        "function": "_sendCmd",
        "class": "Horde_Imap_Client_Socket",
        "type": "->"
      },
      {
        "file": "/var/www/html/apps/mail/vendor/bytestream/horde-imap-client/lib/Horde/Imap/Client/Base.php",
        "line": 888,
        "function": "_logout",
        "class": "Horde_Imap_Client_Socket",
        "type": "->"
      },
      {
        "file": "/var/www/html/apps/mail/lib/Service/Sync/ImapToDbSynchronizer.php",
        "line": 466,
        "function": "logout",
        "class": "Horde_Imap_Client_Base",
        "type": "->"
      },
      {
        "file": "/var/www/html/apps/mail/lib/Service/Sync/ImapToDbSynchronizer.php",
        "line": 235,
        "function": "runPartialSync",
        "class": "OCA\\Mail\\Service\\Sync\\ImapToDbSynchronizer",
        "type": "->"
      },
      {
        "file": "/var/www/html/apps/mail/lib/Service/Sync/ImapToDbSynchronizer.php",
        "line": 136,
        "function": "sync",
        "class": "OCA\\Mail\\Service\\Sync\\ImapToDbSynchronizer",
        "type": "->"
      },
      {
        "file": "/var/www/html/apps/mail/lib/BackgroundJob/SyncJob.php",
        "line": 110,
        "function": "syncAccount",
        "class": "OCA\\Mail\\Service\\Sync\\ImapToDbSynchronizer",
        "type": "->"
      },
      {
        "file": "/var/www/html/lib/public/BackgroundJob/Job.php",
        "line": 78,
        "function": "run",
        "class": "OCA\\Mail\\BackgroundJob\\SyncJob",
        "type": "->"
      },
      {
        "file": "/var/www/html/lib/public/BackgroundJob/TimedJob.php",
        "line": 103,
        "function": "start",
        "class": "OCP\\BackgroundJob\\Job",
        "type": "->"
      },
      {
        "file": "/var/www/html/lib/public/BackgroundJob/TimedJob.php",
        "line": 93,
        "function": "start",
        "class": "OCP\\BackgroundJob\\TimedJob",
        "type": "->"
      },
      {
        "file": "/var/www/html/cron.php",
        "line": 152,
        "function": "execute",
        "class": "OCP\\BackgroundJob\\TimedJob",
        "type": "->"
      }
    ],
    "File": "/var/www/html/lib/private/Log/ErrorHandler.php",
    "Line": 92,
    "CustomMessage": "--"
  }
}

Mail app version

2.2

Mailserver or service

No response

Operating system

No response

PHP engine version

None

Web server

None

Database

None

Additional info

No response

ChristophWurst commented 1 year ago

We already have try-catch for any throwable: https://github.com/nextcloud/mail/blob/e926b63a15f8c9463c07b6496ef0968dbb8b33c9/lib/BackgroundJob/SyncJob.php#L108-L115

ChristophWurst commented 1 year ago

"app":"PHP"

https://github.com/nextcloud/server/blob/73000175d097a5d04cfa9abcfc964fd641ba2021/lib/private/Log/ErrorHandler.php#L82

This is probably a wontfix