{"action":"created","issue":{"url":"https://api.github.com/repos/OptimalBits/bull/issues/948","repository_url":"https://api.github.com/repos/OptimalBits/bull","labels_url":"https://api.github.com/repos/OptimalBits/bull/issues/948/labels{/name}","comments_url":"https://api.github.com/repos/OptimalBits/bull/issues/948/comments","events_url":"https://api.github.com/repos/OptimalBits/bull/issues/948/events","html_url":"https://github.com/OptimalBits/bull/issues/948","id":324594115,"number":948,"title":"Ambiguous Queue.add arguments ","user":{"login":"Cherry","id":856748,"avatar_url":"https://avatars2.githubusercontent.com/u/856748?v=4","gravatar_id":"","url":"https://api.github.com/users/Cherry","html_url":"https://github.com/Cherry","followers_url":"https://api.github.com/users/Cherry/followers","following_url":"https://api.github.com/users/Cherry/following{/other_user}","gists_url":"https://api.github.com/users/Cherry/gists{/gist_id}","starred_url":"https://api.github.com/users/Cherry/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Cherry/subscriptions","organizations_url":"https://api.github.com/users/Cherry/orgs","repos_url":"https://api.github.com/users/Cherry/repos","events_url":"https://api.github.com/users/Cherry/events{/privacy}","received_events_url":"https://api.github.com/users/Cherry/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-05-19T02:29:39Z","updated_at":"2018-05-19T07:54:49Z","closed_at":null,"author_association":"NONE","body":"## Description\r\nFirstly, as per the documentation at https://github.com/OptimalBits/bull/blob/master/REFERENCE.md#queueadd, you can pass `name` as an option to the Queue.add function, and only a handler designated for that name will process jobs. When a handler isn't defined for this job `name`, you receive an error similar to `Missing process handler for job type JOB_NAME`. The documentation doesn't really mention a job `type`, so diagnosing this issue took me longer than I'm willing to admit.\r\n\r\nMore importantly, the arguments for Queue.add seem to be a little ambiguous when passing a string as the `data` with options. When I passed a string such as `my-unique-id-here`, and job options such as `jobId`,`backoff`, etc. Bull processed this as a `name`, and `data`, with no `options`. As an example:\r\n\r\n## Test code to reproduce\r\n```javascript\r\n'use strict';\r\n\r\nconst Queue = require('bull');\r\n\r\nvar myQueue = new Queue('my_queue');\r\n\r\nmyQueue.on('failed', function(job, err){\r\n\tconsole.error('Job ID %s failed', job.id, err);\r\n});\r\n\r\nmyQueue.add('abc-123-foo', {\r\n\tattempts: 3,\r\n\tremoveOnComplete: true,\r\n\tremoveOnFail: true,\r\n\tbackoff: {\r\n\t\tdelay: 15000,\r\n\t\ttype: \"fixed\"\r\n\t}\r\n});\r\n\r\nmyQueue.process(function(job, done){\r\n\tconsole.log('Processing job', job.id, job.data);\r\n\treturn done();\r\n});\r\n\r\nsetTimeout(function(){\r\n\tmyQueue.close();\r\n}, 5000);\r\n```\r\n\r\nThe expected result would be to see:\r\n```\r\nProcessing job 1 'abc-123-foo'\r\n```\r\n\r\nThe actual output is:\r\n```\r\nJob ID 1 failed Error: Missing process handler for job type abc-123-foo\r\n...\r\n```\r\n\r\n## Bull version\r\nTested on Node 8.11.2 and Bull 3.4.2.\r\n\r\n## Additional information\r\nThis can obviously be worked around by passing something like `{id: 'abc-123-foo'}` as my data, but the documentation  definitely does not make this clear. From my memory, this work in previous versions of Bull, but not since updating to 3.x.\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/OptimalBits/bull/issues/comments/390387575","html_url":"https://github.com/OptimalBits/bull/issues/948#issuecomment-390387575","issue_url":"https://api.github.com/repos/OptimalBits/bull/issues/948","id":390387575,"user":{"login":"manast","id":95200,"avatar_url":"https://avatars0.githubusercontent.com/u/95200?v=4","gravatar_id":"","url":"https://api.github.com/users/manast","html_url":"https://github.com/manast","followers_url":"https://api.github.com/users/manast/followers","following_url":"https://api.github.com/users/manast/following{/other_user}","gists_url":"https://api.github.com/users/manast/gists{/gist_id}","starred_url":"https://api.github.com/users/manast/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/manast/subscriptions","organizations_url":"https://api.github.com/users/manast/orgs","repos_url":"https://api.github.com/users/manast/repos","events_url":"https://api.github.com/users/manast/events{/privacy}","received_events_url":"https://api.github.com/users/manast/received_events","type":"User","site_admin":false},"created_at":"2018-05-19T07:54:49Z","updated_at":"2018-05-19T07:54:49Z","author_association":"MEMBER","body":"I am not sure I understand the issue here. Is it that you want to suggest a different signature for the ```add``` method or just a better clarification regarding the name parameter? Just for the sake of it I added an extra sentence regarding this matter."}}
{"actor":{"display_login":"manast"}}