codeforanchorage / courtbot

Your friendly neighborhood court robot. Provides an api for getting court case information.
https://courtbot.codeforanchorage.org
ISC License
7 stars 10 forks source link

Cannot send reminders where there is more then one reminder that needs to be sent #36

Closed robbiepc30 closed 7 years ago

robbiepc30 commented 7 years ago

Expected behavior

What should have happened? When sending reminders, all reminders for the next day should be sent. node runners/sendReminders.js

Actual behavior

What actually happened? The first reminder will be sent but will throw an error on the sendReminder function which will prevent other reminders from being sent. It also halts the execution of the other functions to include the updateReminderStatus so even the reminder that was sent will not be marked as being sent, causing them to get a second message if sendReminders.js is ran again.

Error details

Error: Trying to add data in unsupported state 1 at Decipher.update (crypto.js line 144 col 26) 2 at <unknown> (/Users/xbob/GitRepos/courtbot/sendReminders.js line 46 col 26) var phone = decipher.update(reminder.phone, 'hex', 'utf8') + decipher.final('utf8'); 3 at Promise._execute (/Users/xbob/GitRepos/courtbot/node_modules/bluebird/js/release/debuggability.js line 299 col 9) executor(resolve, reject); 4 at Promise._resolveFromExecutor (/Users/xbob/GitRepos/courtbot/node_modules/bluebird/js/release/promise.js line 481 col 18) var r = this._execute(executor, function(value) { 5 at new Promise (/Users/xbob/GitRepos/courtbot/node_modules/bluebird/js/release/promise.js line 77 col 14) this._resolveFromExecutor(executor); 6 at sendReminder (/Users/xbob/GitRepos/courtbot/sendReminders.js line 45 col 10) return new Promise(function(resolve, reject) { 7 at tryCatcher (/Users/xbob/GitRepos/courtbot/node_modules/bluebird/js/release/util.js line 16 col 23) return target.apply(this, arguments); 8 at MappingPromiseArray._promiseFulfilled (/Users/xbob/GitRepos/courtbot/node_modules/bluebird/js/release/map.js line 61 col 38) var ret = tryCatch(callback).call(receiver, value, index, length); 9 at MappingPromiseArray.PromiseArray._iterate (/Users/xbob/GitRepos/courtbot/node_modules/bluebird/js/release/promise_array.js line 113 col 31) isResolved = this._promiseFulfilled(maybePromise, i); 10 at MappingPromiseArray.init (/Users/xbob/GitRepos/courtbot/node_modules/bluebird/js/release/promise_array.js line 77 col 10) this._iterate(values); 11 at MappingPromiseArray._asyncInit (/Users/xbob/GitRepos/courtbot/node_modules/bluebird/js/release/map.js line 30 col 10) this._init$(undefined, -2); 12 at Async._drainQueue (/Users/xbob/GitRepos/courtbot/node_modules/bluebird/js/release/async.js line 143 col 12) fn.call(receiver, arg); 13 at Async._drainQueues (/Users/xbob/GitRepos/courtbot/node_modules/bluebird/js/release/async.js line 148 col 10) this._drainQueue(this._normalQueue); 14 at Immediate.Async.drainQueues (/Users/xbob/GitRepos/courtbot/node_modules/bluebird/js/release/async.js line 17 col 14) self._drainQueues(); 15 at runCallback (timers.js line 651 col 20) 16 at tryOnImmediate (timers.js line 624 col 5)

Steps to reproduce

  1. From two phones text in a citation for the next day, it happens whether they are the same citation or a different citation. Answer Yes that you want a reminder.
  2. run from root of app node runners/sendReminders.js or heroku heroku run node runners/sendReminders.js
  3. One phone will probably get a reminder sent (you should see the error above in the console). The other phone will not get a reminder. When testing this in heroku the error doesn't show as much detail (not sure as to why)
tescher commented 7 years ago

Fixed