{"action":"created","issue":{"url":"https://api.github.com/repos/bbc/sqs-consumer/issues/125","repository_url":"https://api.github.com/repos/bbc/sqs-consumer","labels_url":"https://api.github.com/repos/bbc/sqs-consumer/issues/125/labels{/name}","comments_url":"https://api.github.com/repos/bbc/sqs-consumer/issues/125/comments","events_url":"https://api.github.com/repos/bbc/sqs-consumer/issues/125/events","html_url":"https://github.com/bbc/sqs-consumer/issues/125","id":358323283,"node_id":"MDU6SXNzdWUzNTgzMjMyODM=","number":125,"title":"handleMessage not reliably invoked","user":{"login":"kodayashi","id":916855,"node_id":"MDQ6VXNlcjkxNjg1NQ==","avatar_url":"https://avatars1.githubusercontent.com/u/916855?v=4","gravatar_id":"","url":"https://api.github.com/users/kodayashi","html_url":"https://github.com/kodayashi","followers_url":"https://api.github.com/users/kodayashi/followers","following_url":"https://api.github.com/users/kodayashi/following{/other_user}","gists_url":"https://api.github.com/users/kodayashi/gists{/gist_id}","starred_url":"https://api.github.com/users/kodayashi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kodayashi/subscriptions","organizations_url":"https://api.github.com/users/kodayashi/orgs","repos_url":"https://api.github.com/users/kodayashi/repos","events_url":"https://api.github.com/users/kodayashi/events{/privacy}","received_events_url":"https://api.github.com/users/kodayashi/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2018-09-08T19:51:39Z","updated_at":"2018-09-19T00:35:29Z","closed_at":null,"author_association":"NONE","body":"The function I'm passing to handleMessage doesn't seem to be reliably invoked. Only about half of the time. I am using async, is that part of the issue. Here's my code snippet:\r\n\r\nConsumer creation:\r\n\r\n```javascript\r\n    const sqs = Consumer.create({\r\n      queueUrl: this.configService.get('SQS_QUEUE_URL'),\r\n      handleMessage: (message, done) => this.handleSQSMessage(message, done),\r\n    });\r\n    sqs.on('error', (error) => this.handleSQSError(error));\r\n    sqs.start();\r\n```\r\n\r\nCallback:\r\n```javascript\r\n  async handleSQSMessage(message, done) {\r\n    console.log('message: ', message);\r\n    await this.someOtherAsyncMethodToUpdateMyDatabase(message);\r\n    done();\r\n  }\r\n```\r\n\r\nThe console log message only fires about half of the time, but 100% of messages are being deleted from the queue somehow."},"comment":{"url":"https://api.github.com/repos/bbc/sqs-consumer/issues/comments/422605452","html_url":"https://github.com/bbc/sqs-consumer/issues/125#issuecomment-422605452","issue_url":"https://api.github.com/repos/bbc/sqs-consumer/issues/125","id":422605452,"node_id":"MDEyOklzc3VlQ29tbWVudDQyMjYwNTQ1Mg==","user":{"login":"kodayashi","id":916855,"node_id":"MDQ6VXNlcjkxNjg1NQ==","avatar_url":"https://avatars1.githubusercontent.com/u/916855?v=4","gravatar_id":"","url":"https://api.github.com/users/kodayashi","html_url":"https://github.com/kodayashi","followers_url":"https://api.github.com/users/kodayashi/followers","following_url":"https://api.github.com/users/kodayashi/following{/other_user}","gists_url":"https://api.github.com/users/kodayashi/gists{/gist_id}","starred_url":"https://api.github.com/users/kodayashi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kodayashi/subscriptions","organizations_url":"https://api.github.com/users/kodayashi/orgs","repos_url":"https://api.github.com/users/kodayashi/repos","events_url":"https://api.github.com/users/kodayashi/events{/privacy}","received_events_url":"https://api.github.com/users/kodayashi/received_events","type":"User","site_admin":false},"created_at":"2018-09-19T00:35:29Z","updated_at":"2018-09-19T00:35:29Z","author_association":"NONE","body":"You should be curious, it doesn't make any sense @cejast.\r\n\r\nAfter a bit of luck I realized there was a rogue service that was also polling SQS, so there was a race condition where the other service was popping items from the queue. The library is working just fine :)\r\n\r\nPassing in an async handler also works fine. Sorry for the false alarm. I suppose on the plus side, I learned quite a bit about async, auto-bind and EventEmitter from this library. Oops!"}}
{"actor":{"display_login":"kodayashi"}}