Merge pull request #1152 from balena-io/1080-cancelDelay-fn

Handle cancelDelay not being a function
This commit is contained in:
CameronDiver 2019-11-28 15:58:27 +00:00 committed by GitHub
commit 1c51e923bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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