-
-
Notifications
You must be signed in to change notification settings - Fork 82
Description
Describe the bug
The hang occurs after fetching the email body text after a second lock. Investigation shows that lock.release() in ImapService may not be working correctly, causing the process to hang indefinitely. Need to debug why the mailbox lock is not being released properly after IMAP operations.
The debug test script debug-imap-lock.ts was created to help debug this issue by making two sequential fetches with proper lock handling. Run it with:
npm run debug-imap
This will prompt for password, connect to IMAP, fetch two emails sequentially, and release locks between each operation to help identify where the hang occurs.
To Reproduce
Steps to reproduce the behavior:
- Script is attached
- Add email in script
- npm run debug-imap
- Enter password when prompted
Expected behavior
Expected no stacktrace
Expected the lock to release.
Expected the second call to client.fetch to succeed
Desktop (please complete the following information):
- OS: iOS
- Node.js v25.2.1
Additional context
Logs of the stacktrace
========== SECOND FETCH ==========
Trace: { msg: 'Requesting lock', path: 'INBOX', lockId: 2, activeLock: null }
at synteticLogger.<computed> [as trace] (/Users/brandon/Documents/projects/emailsort/node_modules/imapflow/lib/imap-flow.js:3657:46)
at ImapFlow.getMailboxLock (/Users/brandon/Documents/projects/emailsort/node_modules/imapflow/lib/imap-flow.js:3615:18)
at main (/Users/brandon/Documents/projects/emailsort/scripts/debug-imap-lock.ts:126:36)
Trace: {
msg: 'Mailbox lock acquired [existing]',
path: 'INBOX',
lockId: 2,
idling: false
}
at synteticLogger.<computed> [as trace] (/Users/brandon/Documents/projects/emailsort/node_modules/imapflow/lib/imap-flow.js:3657:46)
at ImapFlow.processLocks (/Users/brandon/Documents/projects/emailsort/node_modules/imapflow/lib/imap-flow.js:3522:30)
at /Users/brandon/Documents/projects/emailsort/node_modules/imapflow/lib/imap-flow.js:3630:18
at new Promise (<anonymous>)
at ImapFlow.getMailboxLock (/Users/brandon/Documents/projects/emailsort/node_modules/imapflow/lib/imap-flow.js:3628:22)
at main (/Users/brandon/Documents/projects/emailsort/scripts/debug-imap-lock.ts:126:36)
📧 Lock 2 acquired for second fetch