Auto-merge for PR #480 via VersionBot

Avoid an indefinite recursion that grows the call stack when reporting the current state fails
This commit is contained in:
resin-io-versionbot[bot] 2017-11-03 03:59:23 +00:00 committed by GitHub
commit bb350eca92
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 5 deletions

View File

@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file
automatically by Versionist. DO NOT EDIT THIS FILE MANUALLY!
This project adheres to [Semantic Versioning](http://semver.org/).
## v6.4.2 - 2017-11-03
* Avoid an indefinite recursion that grows the call stack when reporting the current state fails #480 [Pablo Carranza Velez]
## v6.4.1 - 2017-11-02
* Improve caching when building gosuper #520 [Pablo Carranza Velez]

View File

@ -1,7 +1,7 @@
{
"name": "resin-supervisor",
"description": "This is resin.io's Supervisor, a program that runs on IoT devices and has the task of running user Apps (which are Docker containers), and updating them as Resin's API informs it to.",
"version": "6.4.1",
"version": "6.4.2",
"license": "Apache-2.0",
"repository": {
"type": "git",

View File

@ -181,7 +181,7 @@ exports.getDeviceType = memoizePromise ->
do ->
APPLY_STATE_SUCCESS_DELAY = 1000
APPLY_STATE_RETRY_DELAY = 5000
applyPromise = Promise.resolve()
applyPending = false
targetState = {}
actualState = {}
updateState = { update_pending: false, update_failed: false, update_downloaded: false }
@ -193,8 +193,10 @@ do ->
applyState = ->
stateDiff = getStateDiff()
if _.size(stateDiff) is 0
applyPending = false
return
applyPromise = Promise.join(
applyPending = true
Promise.join(
utils.getConfig('apiKey')
device.getID()
(apiKey, deviceID) ->
@ -219,7 +221,7 @@ do ->
Promise.delay(APPLY_STATE_RETRY_DELAY)
.finally ->
# Check if any more state diffs have appeared whilst we've been processing this update.
applyState()
setImmediate(applyState)
exports.setUpdateState = (value) ->
_.merge(updateState, value)
@ -238,7 +240,7 @@ do ->
_.merge(targetState, updatedState)
# Only trigger applying state if an apply isn't already in progress.
if !applyPromise.isPending()
if !applyPending
applyState()
return