{"action":"created","issue":{"url":"https://api.github.com/repos/diamondio/better-queue/issues/34","repository_url":"https://api.github.com/repos/diamondio/better-queue","labels_url":"https://api.github.com/repos/diamondio/better-queue/issues/34/labels{/name}","comments_url":"https://api.github.com/repos/diamondio/better-queue/issues/34/comments","events_url":"https://api.github.com/repos/diamondio/better-queue/issues/34/events","html_url":"https://github.com/diamondio/better-queue/issues/34","id":327943467,"node_id":"MDU6SXNzdWUzMjc5NDM0Njc=","number":34,"title":"Precondition delay and retry failure.","user":{"login":"friedhardware","id":29745580,"node_id":"MDQ6VXNlcjI5NzQ1NTgw","avatar_url":"https://avatars1.githubusercontent.com/u/29745580?v=4","gravatar_id":"","url":"https://api.github.com/users/friedhardware","html_url":"https://github.com/friedhardware","followers_url":"https://api.github.com/users/friedhardware/followers","following_url":"https://api.github.com/users/friedhardware/following{/other_user}","gists_url":"https://api.github.com/users/friedhardware/gists{/gist_id}","starred_url":"https://api.github.com/users/friedhardware/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/friedhardware/subscriptions","organizations_url":"https://api.github.com/users/friedhardware/orgs","repos_url":"https://api.github.com/users/friedhardware/repos","events_url":"https://api.github.com/users/friedhardware/events{/privacy}","received_events_url":"https://api.github.com/users/friedhardware/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-05-31T00:09:28Z","updated_at":"2018-06-04T17:08:53Z","closed_at":"2018-06-04T17:08:53Z","author_association":"NONE","body":"The way i've read the documentation is that the precondition function will be called until it passes and there are objects in the queue. Also, precondition retry will be delayed by whatever the timeout is.\r\n\r\nIt looks as if every time an object is added to the queue, it calls the precondition function, ignoring the delay.\r\n\r\nIn addition to the delay being ignored, my code breaks the queue from calling the precondition infinitely and i'm having a hard time figuring out why.\r\n\r\nI've setup a queue with the following code:\r\n````\r\nreceiptQueue = new Queue(function (data, cb) {\r\n        printService.print(data)\r\n            .then(function () {\r\n                cb(null, \"ok\");\r\n            }).catch(function (err) {\r\n            cb(err);\r\n        });\r\n    }, {\r\n        afterProcessDelay: 500,\r\n        maxRetries: 12, retryDelay: 5000,\r\n        precondition: function (cb) {\r\n            printService.isOnline()\r\n                .then(function (result) {\r\n                    if (result) {\r\n                        console.log(\"Online\");\r\n                        cb(null, true);\r\n                    } else {\r\n                        console.log(\"Offline\");\r\n                        cb(null, false);\r\n                    }\r\n                })\r\n\r\n        }, preconditionRetryTimeout: 1000\r\n    }\r\n);\r\n````\r\n\r\nI'm using the latest better-queue and node v8."},"comment":{"url":"https://api.github.com/repos/diamondio/better-queue/issues/comments/394428886","html_url":"https://github.com/diamondio/better-queue/issues/34#issuecomment-394428886","issue_url":"https://api.github.com/repos/diamondio/better-queue/issues/34","id":394428886,"node_id":"MDEyOklzc3VlQ29tbWVudDM5NDQyODg4Ng==","user":{"login":"friedhardware","id":29745580,"node_id":"MDQ6VXNlcjI5NzQ1NTgw","avatar_url":"https://avatars1.githubusercontent.com/u/29745580?v=4","gravatar_id":"","url":"https://api.github.com/users/friedhardware","html_url":"https://github.com/friedhardware","followers_url":"https://api.github.com/users/friedhardware/followers","following_url":"https://api.github.com/users/friedhardware/following{/other_user}","gists_url":"https://api.github.com/users/friedhardware/gists{/gist_id}","starred_url":"https://api.github.com/users/friedhardware/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/friedhardware/subscriptions","organizations_url":"https://api.github.com/users/friedhardware/orgs","repos_url":"https://api.github.com/users/friedhardware/repos","events_url":"https://api.github.com/users/friedhardware/events{/privacy}","received_events_url":"https://api.github.com/users/friedhardware/received_events","type":"User","site_admin":false},"created_at":"2018-06-04T17:08:53Z","updated_at":"2018-06-04T17:08:53Z","author_association":"NONE","body":"This does work for me and it makes sense."}}
{"actor":{"display_login":"friedhardware"}}