Skip to content

Commit

Permalink
Auto-merge for PR #480 via VersionBot
Browse files Browse the repository at this point in the history
Avoid an indefinite recursion that grows the call stack when reporting the current state fails
  • Loading branch information
resin-io-versionbot[bot] committed Nov 3, 2017
2 parents a212d9b + a3b5b03 commit bb350ec
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
10 changes: 6 additions & 4 deletions src/device.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand All @@ -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) ->
Expand All @@ -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)
Expand All @@ -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

Expand Down

0 comments on commit bb350ec

Please sign in to comment.