# Supervisor response for v2/applications/state is incorrect

**URL:** <https://forums.balena.io/t/supervisor-response-for-v2-applications-state-is-incorrect/5246>\
**Category:** Product support\
**Created:** [February 7, 2019, 12:51pm UTC](https://forums.balena.io/t/supervisor-response-for-v2-applications-state-is-incorrect/5246 "2019-02-07T12:51:12Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![krix](https://avatars.discourse-cdn.com/v4/letter/k/b9bd4f/32.png) [@krix](https://forums.balena.io/u/krix)\
**Post date:** [February 7, 2019, 12:51pm UTC](https://forums.balena.io/t/supervisor-response-for-v2-applications-state-is-incorrect/5246/1 "2019-02-07T12:51:12Z")

</div>

I am trying from within my application to detect if an application update/download is in progress.  
I am using pinned releases. And I have delta-updates enabled.

The [`/v2/applications/state` supervisor API](https://github.com/balena-io/balena-supervisor/blob/master/docs/API.md#get-v2applicationsstate) does not report the correct state it seems.

When I pin the device to a later release, it works as expected, the status object says ‘Downloading’ and the progress number grows:

{u’status’: u’Downloading’, u’releaseId’: 784146, u’downloadProgress’: 8}  
{u’status’: u’Downloading’, u’releaseId’: 784146, u’downloadProgress’: 22}  
{u’status’: u’Downloading’, u’releaseId’: 784146, u’downloadProgress’: 35}

However if I pin a device to an older release, the status object remains unaffected:

{u’status’: u’Running’, u’releaseId’: 784146, u’downloadProgress’: None}

… until the application suddenly reboots:

---

<div class="post-metadata">

**Author:** ![thundron](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/thundron/32/1379_2.png) [@thundron](https://forums.balena.io/u/thundron)\
**Post date:** [February 8, 2019, 10:03pm UTC](https://forums.balena.io/t/supervisor-response-for-v2-applications-state-is-incorrect/5246/4 "2019-02-08T22:03:54Z")

</div>

Could you please give us the link to a device in this state, as well as giving support access to the same device? If you had a development device that we could pin different releases on, that would be awesome.  
Be wary though that this might be due to the fact that the download happens fast enough to not trigger any status update on your end, but we would like to investigate anyway.

---

<div class="post-metadata">

**Author:** ![pdcastro](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/pdcastro/32/1264_2.png) [@pdcastro](https://forums.balena.io/u/pdcastro)\
**Post date:** [February 8, 2019, 10:39pm UTC](https://forums.balena.io/t/supervisor-response-for-v2-applications-state-is-incorrect/5246/5 "2019-02-08T22:39:58Z")

</div>

To expand on @thundron’s explanation, “the download happens fast enough” may also mean that a download isn’t required at all because the device already has the required docker image layers in its local cache. You may try to verify whether this is the case by running the following commands on a host OS terminal _before and after_ pinning the device to an older release:  
`balena-engine image ls -a`  
`balena-engine history <imageID>` - for the image ID of the relevant app release

If the relevant image IDs are the same before and after changing the release, no download was necessary. @krix, to clarify, other than missing ‘downloadProgress’ updates, do you mean that everything else happens as expected?

---

<div class="post-metadata">

**Author:** ![krix](https://avatars.discourse-cdn.com/v4/letter/k/b9bd4f/32.png) [@krix](https://forums.balena.io/u/krix)\
**Post date:** [February 20, 2019, 1:50pm UTC](https://forums.balena.io/t/supervisor-response-for-v2-applications-state-is-incorrect/5246/6 "2019-02-20T13:50:17Z")

</div>

Thanks for your quick input, I have not had the time before now to move on with this.  
I cannot make your explanation match with what I see. If the image was already there, the sw change to the older release should be really fast shouldn’t it? But it takes several minutes and the balena log contains a number of "Downloading delta for image… " messages.

Here is the requested output before and after pinning to the older release:

```
root@mydevice:~# balena-engine image ls -a
REPOSITORY TAG IMAGE ID CREATED SIZE
<none> <none> ae569e161f70 26 minutes ago 18B
balena/amd64-supervisor v9.0.1 691733ca7751 2 months ago 44.5MB
root@mydevice:~# balena-engine history ae569e161f70
IMAGE CREATED CREATED BY SIZE COMMENT

root@mydevice:~# balena-engine image ls -a
REPOSITORY TAG IMAGE ID CREATED SIZE
<none> <none> 1789ac240fb5 About a minute ago 18B
balena/amd64-supervisor v9.0.1 691733ca7751 2 months ago 44.5MB
root@mydevice:~# balena-engine history 1789ac240fb5
IMAGE CREATED CREATED BY SIZE COMMENT
```

---

<div class="post-metadata">

**Author:** ![krix](https://avatars.discourse-cdn.com/v4/letter/k/b9bd4f/32.png) [@krix](https://forums.balena.io/u/krix)\
**Post date:** [February 21, 2019, 12:52pm UTC](https://forums.balena.io/t/supervisor-response-for-v2-applications-state-is-incorrect/5246/7 "2019-02-21T12:52:25Z")

</div>

For my purpose I have a workaround: If I query the device state through **/v1/device** , there is an “update\_pending” flag which suits my purpose.

I still wonder why the pending update is not reflected in the response from **v2/applications/state** but I can get by for now.

---

<div class="post-metadata">

**Author:** ![sradevski](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/sradevski/32/1609_2.png) [@sradevski](https://forums.balena.io/u/sradevski)\
**Post date:** [March 4, 2019, 5:30pm UTC](https://forums.balena.io/t/supervisor-response-for-v2-applications-state-is-incorrect/5246/8 "2019-03-04T17:30:35Z")

</div>

Hi there,

Just to update you, we have opened an issue to track this internally and we will let you know once this gets investigated in a bit more detail. It’s great that you found a workaround until we get this fixed.

Best Regards,  
Steve
