Fix double-free: guard against double-destroy of connection
cleanup() was called from conn.on('close'), then called
conn.destroy() on an already-destroyed connection. The double
destroy triggers a native double-free in libudx/SecretStream.
Fix: check conn.destroyed before calling destroy(), and prevent
re-entrant cleanup calls with a guard flag.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
561934a6eb5e2c1c888310d4ec6ade9a81610487
by plankatron <fleeky@gmail.com> · 2026-04-07T13:56:27.000Z