Issue #420: Avoid supervisor crash without connection by properly memoizing promise-returning functions

device.getID caused a fatal error when connection was down, as the memoization with `promise: true` throws
synchronously. Changing memoizee to use `promise: 'then'` makes the memoization work as expected.

Change-Type: patch
Signed-off-by: Pablo Carranza Velez <pablo@resin.io>
This commit is contained in:
Pablo Carranza Velez 2017-04-04 12:10:00 -07:00
parent 962c5c138b
commit 4d322c72a0

View File

@ -13,7 +13,8 @@ bootstrap = require './bootstrap'
{ checkTruthy } = require './lib/validation'
osRelease = require './lib/os-release'
memoizePromise = _.partial(memoizee, _, promise: true)
# If we don't use promise: 'then', exceptions will crash the program
memoizePromise = _.partial(memoizee, _, promise: 'then')
exports.getID = memoizePromise ->