postalsys / emailengine

Headless email client
https://emailengine.app/
Other
1.9k stars 169 forks source link

Failed connections not showing in stats endpoint #468

Closed Jivings closed 1 month ago

Jivings commented 1 month ago

I have lots of failed OAuth connections (which is fine), but the /stats endpoint doesn't surface them, they're all marked as "connected".

CleanShot 2024-11-01 at 08 12 21@2x

/v1/stats output:

{
    "version": "2.48.4",
    "license": "LICENSE_EMAILENGINE",
    "accounts": 432,
    "node": "20.18.0",
    "redis": "7.4.0",
    "redisCluster": false,
    "imapflow": "1.0.164",
    "bullmq": "5.21.2",
    "arch": "x64",
    "counters": {...},
    "queues": {...},
    "connections": {
        "init": 0,
        "connected": 432,
        "connecting": 0,
        "authenticationError": 0,
        "connectError": 0,
        "unset": 0,
        "disconnected": 0
    },
    "redisPing": 258479,
    "build": {
        "commit": "",
        "time": "1729867672893"
    }
}
andris9 commented 1 month ago

I was doing a new release, so I squeezed in a fix for this as well. Available in v2.48.6. The reason was that the state counter only checked the IMAP TCP connection status. There is no such connection for API clients, so the connection status always defaulted to "connected". EmailEngine now uses the last known state for these accounts.

Jivings commented 1 month ago

Great thank you!