{"action":"closed","issue":{"url":"https://api.github.com/repos/mscdex/node-imap/issues/580","repository_url":"https://api.github.com/repos/mscdex/node-imap","labels_url":"https://api.github.com/repos/mscdex/node-imap/issues/580/labels{/name}","comments_url":"https://api.github.com/repos/mscdex/node-imap/issues/580/comments","events_url":"https://api.github.com/repos/mscdex/node-imap/issues/580/events","html_url":"https://github.com/mscdex/node-imap/issues/580","id":191300779,"number":580,"title":"setFlags not working after IDLE","user":{"login":"silverwind","id":115237,"avatar_url":"https://avatars.githubusercontent.com/u/115237?v=3","gravatar_id":"","url":"https://api.github.com/users/silverwind","html_url":"https://github.com/silverwind","followers_url":"https://api.github.com/users/silverwind/followers","following_url":"https://api.github.com/users/silverwind/following{/other_user}","gists_url":"https://api.github.com/users/silverwind/gists{/gist_id}","starred_url":"https://api.github.com/users/silverwind/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/silverwind/subscriptions","organizations_url":"https://api.github.com/users/silverwind/orgs","repos_url":"https://api.github.com/users/silverwind/repos","events_url":"https://api.github.com/users/silverwind/events{/privacy}","received_events_url":"https://api.github.com/users/silverwind/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-11-23T15:18:31Z","updated_at":"2016-12-06T17:26:09Z","closed_at":"2016-12-06T17:26:09Z","body":"I'm hitting a puzzling issue where `setFlags` seems to not work after a fetch and after the client sends the `IDLE` (I'm doing some async action after the messages are parsed).\r\n\r\nHere's a example that will flag all unflagged messages:\r\n\r\n````js\r\nmodule.exports.test = function() {\r\n  var imap = new Imap(opts);\r\n  imap.once(\"ready\", function() {\r\n    imap.openBox(\"INBOX\", false, function(_err) {\r\n      imap.search([\"UNFLAGGED\"], function(_err, results) {\r\n        imap.fetch(results, {bodies: \"\"}).on(\"message\", function(_, seq) {\r\n          setTimeout(function() { // problematic timeout\r\n            console.log(\"flagging\", seq);\r\n            imap.seq.addFlags(seq, \"\\\\Flagged\", function(err) {\r\n              if (err) console.error(err);\r\n              console.log(\"flagged\", seq);\r\n            });\r\n          }, 3000);\r\n        });\r\n      });\r\n    });\r\n  }).on(\"error\", console.error).connect();\r\n};\r\n````\r\n\r\nThis results in the following debug log (after fetch). Notice the `addFlags` callback is never triggered:\r\n````\r\n<= 'A6 OK Fetch completed (0.002 + 0.000 + 0.001 secs).'\r\n=> 'IDLE IDLE'\r\n<= '+ idling'\r\nflagging 7623\r\n=> DONE\r\nflagging 7624\r\nflagging 7625\r\nflagging 7626\r\nflagging 7627\r\n<= 'IDLE OK Idle completed (0.001 + 2.999 + 2.998 secs).'\r\n````\r\n\r\nNow, when you remove the `setTimeout`, it works as expected:\r\n````\r\n<= 'A6 OK Fetch completed (0.002 + 0.000 + 0.001 secs).'\r\n=> 'A7 STORE 7625 +FLAGS.SILENT (\\\\Flagged)'\r\nflagging 7626\r\nflagging 7627\r\n<= '* 7625 FETCH (MODSEQ (10070))'\r\n<= 'A7 OK Store completed (0.001 + 0.000 secs).'\r\nflagged 7625\r\n=> 'A8 STORE 7626 +FLAGS.SILENT (\\\\Flagged)'\r\n<= '* 7626 FETCH (MODSEQ (10071))'\r\n<= 'A8 OK Store completed (0.001 + 0.000 secs).'\r\nflagged 7626\r\n=> 'A9 STORE 7627 +FLAGS.SILENT (\\\\Flagged)'\r\n<= '* 7627 FETCH (MODSEQ (10072))'\r\n<= 'A9 OK Store completed (0.001 + 0.000 secs).'\r\nflagged 7627\r\n=> 'IDLE IDLE'\r\n<= '+ idling'\r\n````\r\n\r\nIt almost seems like there's a bug that prevents `setFlags` from working after the `IDLE` command has been sent."}}
{"actor":{"display_login":"silverwind"}}