mirror of
https://github.com/wekan/wekan.git
synced 2026-11-25 04:49:41 -05:00
Operators reported that after an update WeKan "dies really quickly", restarts did not help, and it "kills our openldap server with too many open connections"; others saw logins hang for minutes then fail with "Must be logged in". Every LDAP login attempt (loginHandler.js) and every background sync tick (sync.js) created a new LDAP() and connect()ed but NEVER called disconnect() on any path, so each attempt - including every failed login and every one-minute sync tick - leaked a socket to the LDAP/AD server until it hit its connection limit and started refusing connections, taking it and all WeKan logins down. Guarantee release on every exit path: a shared runWithLdapDisconnect() helper (connectionGuard.js) disconnects in a finally; the login handler runs its whole flow through it; background sync() disconnects in a finally; importNewUsers() disconnects only the connection it owns; and LDAP.disconnect() is a safe no-op when connect() was never reached. Adds behavioural + negative + source-guard tests (tests/ldapConnectionRelease.test.cjs, wired into test:unit:node). Also bumps the bundled FerretDB whose SQLite pool no longer caps MaxOpenConns at 16 (that starved WeKan's cursor load: minutes-long board loads, failed logins). Thanks to xet7.