node-red-contrib-tuya-local icon indicating copy to clipboard operation
node-red-contrib-tuya-local copied to clipboard

ReferenceError: timeout is not defined

Open andreypopov opened this issue 5 years ago • 10 comments

(node:63079) UnhandledPromiseRejectionWarning: ReferenceError: timeout is not defined at TuyaDevice. (/Users/apopov/.node-red/node_modules/node-red-contrib-tuya-local/tuya-local.js:74:17) at TuyaDevice.emit (events.js:200:13) at Socket. (/Users/apopov/.node-red/node_modules/node-red-contrib-tuya-local/node_modules/tuyapi/index.js:367:16) at Socket.emit (events.js:205:15) at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1040:10) (node:63079) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1) (node:63079) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

andreypopov avatar Aug 12 '19 09:08 andreypopov

Try to update to the latest.

subzero79 avatar Aug 12 '19 10:08 subzero79

Any luck?

subzero79 avatar Aug 12 '19 23:08 subzero79

pls. add tag node-red to package.json, update version hard to install and update right now

andreypopov avatar Aug 13 '19 06:08 andreypopov

The package is not yet published to npm. I’ll sort that out during the week. I need to make sure is working properly. Did you update the node to latest and is it working ?

subzero79 avatar Aug 13 '19 07:08 subzero79

node-red crashes at start

13 Aug 10:04:26 - [red] Uncaught Exception: 13 Aug 10:04:26 - TypeError: Cannot read property 'replace' of undefined at filterCommandByte (/Users/apopov/.node-red/node_modules/node-red-contrib-tuya-local/lib/utils.js:48:18) at TuyaDevice. (/Users/apopov/.node-red/node_modules/node-red-contrib-tuya-local/tuya-local.js:114:16) at TuyaDevice.emit (events.js:200:13) at TuyaDevice._packetHandler (/Users/apopov/.node-red/node_modules/node-red-contrib-tuya-local/node_modules/tuyapi/index.js:411:10) at /Users/apopov/.node-red/node_modules/node-red-contrib-tuya-local/node_modules/tuyapi/index.js:315:43 at Array.forEach () at Socket. (/Users/apopov/.node-red/node_modules/node-red-contrib-tuya-local/node_modules/tuyapi/index.js:311:19) at Socket.emit (events.js:200:13) at addChunk (_stream_readable.js:294:12) at readableAddChunk (_stream_readable.js:275:11)

andreypopov avatar Aug 13 '19 07:08 andreypopov

I cannot reproduce this, did just update? are you using the commandByte filter?

subzero79 avatar Aug 13 '19 07:08 subzero79

2019-08-13_10-10-34

Just add extra check

function filterCommandByte(msg,cmd_bytes) {
	if (!cmd_bytes) return null;
	arr = cmd_bytes.replace(/\s/g,"").split(",");
	arr = arr.map(function (x) { 
  		return parseInt(x, 10); 
	});
	return (arr.includes(msg.commandByte)) ? null : msg;
}

next issue is:

(node:73782) UnhandledPromiseRejectionWarning: TypeError: Cannot read property '1' of undefined at /Users/apopov/.node-red/node_modules/node-red-contrib-tuya-local/node_modules/tuyapi/index.js:122:29 at processTicksAndRejections (internal/process/task_queues.js:89:5) (node:73782) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1) (node:73782) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

andreypopov avatar Aug 13 '19 07:08 andreypopov

The second error is tuyapi, nothing we can do there.

I cannot reproduce the first one, not an expert in this. What node version is this ?

subzero79 avatar Aug 13 '19 07:08 subzero79

node v12.4.0 node-red v0.20.7

andreypopov avatar Aug 13 '19 07:08 andreypopov

Just tested with v12.4.0 and is working fine. Did you maybe duplicate the node with same ip address?

subzero79 avatar Aug 13 '19 08:08 subzero79