WebThingsIO / gateway

WebThings Gateway - a self-hosted web application for monitoring and controlling a building over the web
http://webthings.io/gateway
Mozilla Public License 2.0
2.62k stars 339 forks source link

Trying to remove a thing sometimes doesn't #1013

Closed dhylands closed 4 years ago

dhylands commented 6 years ago

If I try to remove a thing which the thing-url-adapter can no longer talk to, then it fails. I see the following in run-app.log:

2018-05-17 09:50:19.598 getValue for property on for: ESP32-RGB-LED returning true
2018-05-17 09:50:19.604 getValue for property color for: ESP32-RGB-LED returning #f9ff04
2018-05-17 09:50:21.615 thing-url: AddonManagerProxy: No such device: http---10.252.33.236-
2018-05-17 09:50:21.615 thing-url: AddonManagerProxy: Ignoring msg: { messageType: 'removeThing',
2018-05-17 09:50:21.616 thing-url:   data: 
2018-05-17 09:50:21.616 thing-url:    { deviceId: 'http---10.252.33.236-',
2018-05-17 09:50:21.616 thing-url:      adapterId: 'thing-url-adapter',
2018-05-17 09:50:21.616 thing-url:      pluginId: 'thing-url-adapter' } }

and on the web console I see:

Error removing thing Internal Server Error context-menu.js:74:9
    handleRemove/< webpack:///./static/js/context-menu.js?:74:9

Disabling the thing-url-adapter will cause the thing to be removed.

mrstegeman commented 6 years ago

I'm unable to reproduce this. Was this with the latest gateway and thing-url-adapter?

dhylands commented 6 years ago

I'll have to check exactly which versions I was using. I'll try to keep better track and see if I can up with a set of steps to reproduce this. I've run into this quite a few times recently while trying to work with the thing-url-adapter.

sogaani commented 6 years ago

When the gateway try to pairing devices, thing-url-adapter remove device temporally and add device again. https://github.com/mozilla-iot/thing-url-adapter/blob/master/thing-url-adapter.js#L448 Perhaps, If we try to remove thing between remove device and add device, we can reproduce this issue.

Maybe reproduce steps.

dhylands commented 6 years ago

I also run into this with the zigbee adapter. There, I think what happens is that the unpairing process gets started and never completes (and handleDeviceRemoved never gets called).

With the thing-url-adapter, if removing the device from the config fails, then it also doesn't call handleDeviceRemoved