question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

UnhandledPromiseRejectionWarning

See original GitHub issue
UnhandledPromiseRejectionWarning: Error: TCP Timeout
at Timeout.setTimeout [as _onTimeout] (/.../node_modules/tplink-smarthome-api/lib/client.js:228:20)
    at listOnTimeout (internal/timers.js:535:17)
    at processTimers (internal/timers.js:479:7)

script as easy as

client.getDevice({host: '192.168.1.126'}).then((device)=>{
 device.setPowerState(true);
 console.log( d.toLocaleTimeString() + ' power on!');
 timeoutObj = setTimeout(pOff, 30*1000); // 30s -> off
});

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:12 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
plasticrakecommented, Jun 21, 2020

I’m still not able to replicate this issue, at least not in the current version. I don’t get any unhandled rejections.

tplink-smarthome-api: v2.0.0 node --version: v12.16.3

const debug = require("debug")("poll");
const { Client } = require("tplink-smarthome-api");

const validHost = "10.0.1.160";
const unreachableHost = "192.0.2.0";

const client = new Client();

debug("Attempting to get device");
client.getDevice({ host: validHost }).then((device) => {
  debug("Got device");

  device.host = unreachableHost;
  device.startPolling(1000);

  device.on("polling-error", (err) => {
    debug("polling-error");
    console.dir(err);
  });
});
$  DEBUG=poll node poll.js

  poll Attempting to get device +0ms
  poll Got device +391ms
TCP 192.0.2.0:9999 Error: TCP Timeout
    at Timeout._onTimeout (/Users/patrick/Code/tptest/node_modules/tplink-smarthome-api/lib/network/tcp-socket.js:62:22)
    at listOnTimeout (internal/timers.js:549:17)
    at processTimers (internal/timers.js:492:7)
  poll polling-error +10s
Error: TCP Timeout
    at Timeout._onTimeout (/Users/patrick/Code/tptest/node_modules/tplink-smarthome-api/lib/network/tcp-socket.js:62:22)
    at listOnTimeout (internal/timers.js:549:17)
    at processTimers (internal/timers.js:492:7)

And when I disable my networking:

  poll polling-error +1s
Error: connect ENETUNREACH 192.0.2.0:9999 - Local (0.0.0.0:52343)
    at internalConnect (net.js:921:16)
    at defaultTriggerAsyncIdScope (internal/async_hooks.js:296:12)
    at net.js:1011:9
    at processTicksAndRejections (internal/process/task_queues.js:79:11) {
  errno: 'ENETUNREACH',
  code: 'ENETUNREACH',
  syscall: 'connect',
  address: '192.0.2.0',
  port: 9999
}
TCP 192.0.2.0:9999 Error: connect ENETUNREACH 192.0.2.0:9999 - Local (0.0.0.0:52346)
    at internalConnect (net.js:921:16)
    at defaultTriggerAsyncIdScope (internal/async_hooks.js:296:12)
    at net.js:1011:9
    at processTicksAndRejections (internal/process/task_queues.js:79:11) {
  errno: 'ENETUNREACH',
  code: 'ENETUNREACH',
  syscall: 'connect',
  address: '192.0.2.0',
  port: 9999
}
  poll polling-error +1s
Error: connect ENETUNREACH 192.0.2.0:9999 - Local (0.0.0.0:52346)
    at internalConnect (net.js:921:16)
    at defaultTriggerAsyncIdScope (internal/async_hooks.js:296:12)
    at net.js:1011:9
    at processTicksAndRejections (internal/process/task_queues.js:79:11) {
  errno: 'ENETUNREACH',
  code: 'ENETUNREACH',
  syscall: 'connect',
  address: '192.0.2.0',
  port: 9999
}
TCP 192.0.2.0:9999 Error: connect ENETUNREACH 192.0.2.0:9999 - Local (0.0.0.0:52347)
    at internalConnect (net.js:921:16)
    at defaultTriggerAsyncIdScope (internal/async_hooks.js:296:12)
    at net.js:1011:9
    at processTicksAndRejections (internal/process/task_queues.js:79:11) {
  errno: 'ENETUNREACH',
  code: 'ENETUNREACH',
  syscall: 'connect',
  address: '192.0.2.0',
  port: 9999
}
0reactions
DavidBurgcommented, Jul 4, 2020

@plasticrake Thanks. I ran some tests with different versions of nodejs and tplink-smarthome-api on docker. I got variable stack traces on the ENETUNREACH error, but no unhandled rejections after 1.2.0. So, I think 1.3.0 fixed the problem.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Getting a UnhandledPromiseRejectionWarning when ...
On the console I'm getting an 'UnhandledPromiseRejectionWarning' even though the reject function is getting called since it instantly shows the message ...
Read more >
What is UnhandledPromiseRejectionWarning
The Promise.reject() method returns a Promise object that is rejected with a given reason. The unhandledrejection event is sent to the global scope...
Read more >
Fixing UnhandledPromiseRejectionWarning in Node.js
If we fail to handle a Promise rejection, we're shown the UnhandledPromiseRejectionWarning by Node.js. const slowAndSteady = new Promise( ...
Read more >
Unhandled Promise Rejections in Node.js
If you want to suppress the unhandled promise rejection warning, all you need to do is call .catch() on the promise with an...
Read more >
Unhandled Promise Rejection Warning
I keep getting this error when I run my code UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found