Handle cancelDelay not being a function

Change-type: patch
Closes: #1080
Signed-off-by: Cameron Diver <cameron@balena.io>
This commit is contained in:
Cameron Diver 2019-11-28 10:20:45 +00:00
parent c04ec45f96
commit f4605d897e
No known key found for this signature in database
GPG Key ID: 49690ED87032539F

View File

@ -469,8 +469,10 @@ module.exports = class DeviceState extends EventEmitter
if !@scheduledApply? || (isFromApi && @cancelDelay)
@scheduledApply = { force, delay }
if isFromApi
# Cancel promise delay if call came from api to prevent waiting due to backoff
@cancelDelay()
# Cancel promise delay if call came from api to
# prevent waiting due to backoff (and if we've
# previously setup a delay)
@cancelDelay?()
else
# If a delay has been set it's because we need to hold off before applying again,
# so we need to respect the maximum delay that has been passed