node-imap
node-imap copied to clipboard
Gmail adding/deleting flags, cannot read property 'fullcmd'
Unfortunately, I'm getting an error that this._curReq is undefined in Connection.js when I'm adding/deleting flags from my gmail imap:
Error
<= '* 3 FETCH (UID 4 MODSEQ (26109) FLAGS (\\Seen))'
TypeError: Cannot read property 'fullcmd' of undefined
at ImapPromises.Connection._resUntagged (/Users/delsner/workspace/email-client/emailappserver/node_modules/imap/lib/Connection.js:1403:44)
at Parser.<anonymous> (/Users/delsner/workspace/email-client/emailappserver/node_modules/imap/lib/Connection.js:190:10)
at emitOne (events.js:96:13)
at Parser.emit (events.js:188:7)
at Parser._resUntagged (/Users/delsner/workspace/email-client/emailappserver/node_modules/imap/lib/Parser.js:271:10)
at Parser._parse (/Users/delsner/workspace/email-client/emailappserver/node_modules/imap/lib/Parser.js:137:16)
at Parser._tryread (/Users/delsner/workspace/email-client/emailappserver/node_modules/imap/lib/Parser.js:82:15)
at TLSSocket.Parser._cbReadable (/Users/delsner/workspace/email-client/emailappserver/node_modules/imap/lib/Parser.js:53:12)
at emitNone (events.js:86:13)
at TLSSocket.emit (events.js:185:7)
at emitReadable_ (_stream_readable.js:438:10)
at emitReadable (_stream_readable.js:432:7)
at readableAddChunk (_stream_readable.js:183:13)
at TLSSocket.Readable.push (_stream_readable.js:130:10)
at TLSWrap.onread (net.js:542:20)
at Socket.ondata (_stream_wrap.js:58:20)
at emitOne (events.js:96:13)
at Socket.emit (events.js:188:7)
at readableAddChunk (_stream_readable.js:172:18)
at Socket.Readable.push (_stream_readable.js:130:10)
at TCP.onread (net.js:542:20)
Adding/Deleting flags
// config
this.imap['connTimeout'] = 30000;
this.imap['authTimeout'] = 30000;
this.imap['keepAlive'] = false;
// 1st version
this.imap.addFlags(msgId, flags, (err) => {
this.imap.closeBox(false, () => {
err ? reject(err) : resolve(msgId);
});
})
// 2nd version
this.imap.addFlags(msgId, flags, (err) => {
err ? reject(err) : resolve(msgId);
})
I'm creating a connection on every server request which is then ended (this.imap.end()) before the response is sent to the user. As I have a stateless server-architecture I'm limited to this approach.
I appreciate any help! Thanks.
@delsner can you please share how you fixed the issue?
@ayounas02 this was a long time ago and I don't remember how I eventually solved it. But I do know that I ended up writing a Gmail-specific connector on top of the regular IMAP connector. Hope this helps!
thanks @delsner for the quick response.