Skip to content
This repository has been archived by the owner on Nov 24, 2023. It is now read-only.

promise.then(...).catch(...).done is not a function #81

Closed
atus opened this issue May 17, 2019 · 10 comments
Closed

promise.then(...).catch(...).done is not a function #81

atus opened this issue May 17, 2019 · 10 comments

Comments

@atus
Copy link

atus commented May 17, 2019

I get the error below. As part of debugging this I did the following:

  • reinstalled node and npm with correct versions
  • reinstalled pimatic-hap from pimatic
  • reinstalled pimatic-hap from git and ran npm install from its directory

If I disable all devices I can set up a new home. As soon as I add a simple GpioSwitch I get the error below.

pimatic version 0.9.48
Node.js version 4.9.1
pimatic-hap version 0.11.1

I do not use tradfri where other people have reported errors previously.

Interestingly, when I add a single PowerSwitch I get this error but I can control the switch from Home app. The error appears if I open the app or click on the control.

22:32:30.574 [pimatic-hap] [fa:fe:db:e4:36:2c] HAP Request: POST /pair-verify
22:32:30.582 [pimatic-hap] [fa:fe:db:e4:36:2c] Pair verify step 1/2
22:32:30.994 [pimatic-hap] [fa:fe:db:e4:36:2c] HAP Request: POST /pair-verify
22:32:31.000 [pimatic-hap] [fa:fe:db:e4:36:2c] Pair verify step 2/2
22:32:31.010 [pimatic-hap] [fa:fe:db:e4:36:2c] Client 14101D25-D25F-46BD-B6C6-5ABADB6585E0 verification complete
22:32:31.147 [pimatic-hap] [fa:fe:db:e4:36:2c] HAP Request: GET /accessories
22:32:31.193 [pimatic-hap] [fa:fe:db:e4:36:2c] HAP Request: PUT /characteristics
22:32:31.199 [pimatic-hap] [Pimatic HomeKit Bridge] Processing characteristic set: [{"aid":2,"iid":9,"ev":true}]
22:32:31.203 [pimatic-hap] [Pimatic HomeKit Bridge] Registering Characteristic "Reachable" for events
22:32:31.881 [pimatic-hap] [fa:fe:db:e4:36:2c] HAP Request: PUT /characteristics
22:32:31.884 [pimatic-hap] [Pimatic HomeKit Bridge] Processing characteristic set: [{"aid":2,"iid":15,"ev":true}]
22:32:31.887 [pimatic-hap] [Pimatic HomeKit Bridge] Registering Characteristic "On" for events
22:32:31.995 [pimatic-hap] [fa:fe:db:e4:36:2c] HAP Request: PUT /characteristics
22:32:31.998 [pimatic-hap] [Pimatic HomeKit Bridge] Processing characteristic set: [{"aid":2,"iid":15,"ev":true}]
22:32:32.000 [pimatic-hap] [Pimatic HomeKit Bridge] Registering Characteristic "On" for events
22:32:34.354 [pimatic-hap] [fa:fe:db:e4:36:2c] HAP Request: GET /characteristics?id=2.15
22:32:34.363 [pimatic-hap] [Pimatic HomeKit Bridge] Getting value for Characteristic "On"
22:32:34.427 [pimatic] An uncaught exception occurred: TypeError: promise.then(...).catch(...).done is not a function
22:32:34.427 [pimatic]>    at PowerSwitchAccessory.BaseAccessory.handleReturnPromise (/home/pi/pimatic-app/node_modules/pimatic-hap/accessories/base.coffee:75:10)
22:32:34.427 [pimatic]>    at PowerSwitchAccessory.handleReturnPromise (/home/pi/pimatic-app/node_modules/pimatic-hap/accessories/base.coffee:1:1)
22:32:34.427 [pimatic]>    at null.<anonymous> (/home/pi/pimatic-app/node_modules/pimatic-hap/accessories/switch.coffee:39:12)
22:32:34.427 [pimatic]>    at emitThree (events.js:97:13)
22:32:34.427 [pimatic]>    at null.emit (events.js:175:7)
22:32:34.427 [pimatic]>    at null.Characteristic.getValue (/home/pi/pimatic-app/node_modules/pimatic-hap/node_modules/hap-nodejs/lib/Characteristic.js:142:10)
22:32:34.427 [pimatic]>    at Bridge.<anonymous> (/home/pi/pimatic-app/node_modules/pimatic-hap/node_modules/hap-nodejs/lib/Accessory.js:706:20)
22:32:34.427 [pimatic]>    at Array.forEach (native)
22:32:34.427 [pimatic]>    at Bridge.Accessory._handleGetCharacteristics (/home/pi/pimatic-app/node_modules/pimatic-hap/node_modules/hap-nodejs/lib/Accessory.js:670:8)
22:32:34.427 [pimatic]>    at emitMany (events.js:108:13)
22:32:34.427 [pimatic]>    at HAPServer.emit (events.js:182:7)
22:32:34.427 [pimatic]>    at HAPServer._handleCharacteristics (/home/pi/pimatic-app/node_modules/pimatic-hap/node_modules/hap-nodejs/lib/HAPServer.js:926:10)
22:32:34.427 [pimatic]>    at HAPServer.<anonymous> (/home/pi/pimatic-app/node_modules/pimatic-hap/node_modules/hap-nodejs/lib/HAPServer.js:209:39)
22:32:34.427 [pimatic]>    at emitNone (events.js:67:13)
22:32:34.427 [pimatic]>    at IncomingMessage.emit (events.js:166:7)
22:32:34.427 [pimatic]>    at endReadableNT (_stream_readable.js:923:12)
22:32:34.427 [pimatic]>    at nextTickCallbackWith2Args (node.js:511:9)
22:32:34.427 [pimatic]>    at process._tickDomainCallback (node.js:466:17)
22:32:34.427 [pimatic]> This is most probably a bug in pimatic or in a module, please report it!
22:32:34.437 [pimatic] shutting pimatic down...
@newschooler
Copy link

newschooler commented May 20, 2019

Same error on my site

An uncaught exception occurred: TypeError: promise.then(...).catch(...).done is not a function
    at PowerSwitchAccessory.BaseAccessory.handleReturnPromise (/home/pi/pimatic-app/node_modules/pimatic-hap/accessories/base.coffee:75:10)
    at PowerSwitchAccessory.handleReturnPromise (/home/pi/pimatic-app/node_modules/pimatic-hap/accessories/base.coffee:1:1)
    at null.<anonymous> (/home/pi/pimatic-app/node_modules/pimatic-hap/accessories/switch.coffee:39:12)
    at emitThree (events.js:97:13)
    at null.emit (events.js:175:7)
    at null.Characteristic.getValue (/home/pi/pimatic-app/node_modules/pimatic-hap/node_modules/hap-nodejs/lib/Characteristic.js:142:10)
    at Bridge.<anonymous> (/home/pi/pimatic-app/node_modules/pimatic-hap/node_modules/hap-nodejs/lib/Accessory.js:706:20)
    at Array.forEach (native)
    at Bridge.Accessory._handleGetCharacteristics (/home/pi/pimatic-app/node_modules/pimatic-hap/node_modules/hap-nodejs/lib/Accessory.js:670:8)
    at emitMany (events.js:108:13)
    at HAPServer.emit (events.js:182:7)
    at HAPServer._handleCharacteristics (/home/pi/pimatic-app/node_modules/pimatic-hap/node_modules/hap-nodejs/lib/HAPServer.js:926:10)
    at HAPServer.<anonymous> (/home/pi/pimatic-app/node_modules/pimatic-hap/node_modules/hap-nodejs/lib/HAPServer.js:209:39)
    at emitNone (events.js:67:13)
    at IncomingMessage.emit (events.js:166:7)
    at endReadableNT (_stream_readable.js:923:12)
    at nextTickCallbackWith2Args (node.js:458:9)
    at process._tickCallback (node.js:372:17)
 This is most probably a bug in pimatic or in a module, please report it!

@michbeck100
Copy link
Owner

@newschooler Can you tell which type of device is used?

@michbeck100
Copy link
Owner

@atus I suspect the pimatic-gpio plugin, because it was updated recently. Could you try to revert back to the version before, which would be 0.9.0? Especially is suspect pimatic/pimatic-gpio@35b6472

michbeck100 referenced this issue in pimatic/pimatic-gpio May 22, 2019
@newschooler
Copy link

newschooler commented May 22, 2019

@newschooler Can you tell which type of device is used?

Sorry, it's the GpioSwitch as well. I will try to revert and report then.

edit: @michbeck100 I just moved back to pimatic-gpio 0.9.0 plugin and the error is gone.

@atus
Copy link
Author

atus commented Jun 1, 2019

confirming that downgrading to pimatic/pimatic-gpio 0.9.0 solves the issue

michbeck100 added a commit that referenced this issue Jun 17, 2019
@michbeck100
Copy link
Owner

Version 0.11.2 should fix this issue. I had the same problem with pimatic-sysinfo, so it was easy to find the problem then.

@mwittig
Copy link

mwittig commented Jun 18, 2019

Why do you use done() in this context? It should not be used with bluebird promises and it is not part of the standard for native promise. If I recap this correctly done() is used as part of Q, but Q promises should be wrapped by the plugin as much as possible, as the are considered harmful

@michbeck100
Copy link
Owner

@mwittig to be honest, I'm not a JS professional, I've just seen other plugins and pimatic itself using done() (see here) Would be great if you have an example how to use it right, and I will change it for the next release

@michbeck100 michbeck100 reopened this Jun 18, 2019
@mwittig
Copy link

mwittig commented Jun 18, 2019

Well, me neither. See

Needs further investigation which type of promise it is, as native and bluebird promise should have done() defined. Also it should be investigate which strategy is the best to avoid such issues:

The use in the pimatic code itself is for historical reasons

@michbeck100
Copy link
Owner

Should be solved together with #78

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants