travisghansen/node-red-contrib-kubernetes-client

UnhandledPromiseRejectionWarning: TypeError: node.watch.on is not a function

jdesai61 opened this issue · 12 comments

I just tried this node, but I am getting following error from watch node as soon as it is launched. Is this a version incompatibility or such? Here are my version
10 Jun 18:07:01 - [info] Node-RED version: v1.0.6
10 Jun 18:07:01 - [info] Node.js version: v14.4.0
10 Jun 18:07:01 - [info] Linux 4.15.0-101-generic x64 LE

10 Jun 18:04:14 - [info] [kubernetes-client-watch:f4e2057d.ef7178] watching https://myhost:6443/api/v1/pods from resourceVersion: 258446
(node:6676) UnhandledPromiseRejectionWarning: TypeError: node.watch.on is not a function
at KubernetesClientWatchNode.node.startWatch (/home/ubuntu/.node-red/node_modules/node-red-contrib-kubernetes-client/src/index.js:336:18)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
(Use node --trace-warnings ... to show where the warning was created)
(node:6676) 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(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)

Thanks for the interest! I’ll take a closer look in a few minutes. This is for a watch node or the http node? I’m guessing the watch based on the error but want to make sure..

Are you comfortable seeing what version of the @kubernetes/client-node got installed? This error is quite strange unless the underlying library somehow updated..

Did the node ever work or has it failed from the begining?

{
"_from": "@kubernetes/client-node@^0.11.0",
"_id": "@kubernetes/client-node@0.11.2",
"_inBundle": false,
"_integrity": "sha512-Uhwd2y2qCvugICnHRC5h2MT5vw0a1dJPVVltVwmkeMuyGTPBccsTtpTcSfSLitwOrh4yr+9wG5bRcMdgeRjYPw==",
"_location": "/@kubernetes/client-node",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "@kubernetes/client-node@^0.11.0",
"name": "@kubernetes/client-node",
"escapedName": "@kubernetes%2fclient-node",
"scope": "@kubernetes",
"rawSpec": "^0.11.0",
"saveSpec": null,
"fetchSpec": "^0.11.0"
},
"_requiredBy": [
"/node-red-contrib-kubernetes-client"
],
"_resolved": "https://registry.npmjs.org/@kubernetes/client-node/-/client-node-0.11.2.tgz",
"_shasum": "5dbc1d66d3c954af0f3bd294dece884737f5b761",
"_spec": "@kubernetes/client-node@^0.11.0",
"_where": "/home/ubuntu/.node-red/node_modules/node-red-contrib-kubernetes-client",
"author": {
"name": "Kubernetes Authors"
},
"bugs": {
"url": "https://github.com/kubernetes-client/javascript/issues"
},
"bundleDependencies": false,
"dependencies": {
"@types/js-yaml": "^3.12.1",
"@types/node": "^10.12.0",
"@types/request": "^2.47.1",
"@types/underscore": "^1.8.9",
"@types/ws": "^6.0.1",
"byline": "^5.0.0",
"execa": "1.0.0",
"isomorphic-ws": "^4.0.1",
"js-yaml": "^3.13.1",
"jsonpath-plus": "^0.19.0",
"openid-client": "2.5.0",
"request": "^2.88.0",
"rfc4648": "^1.3.0",
"shelljs": "^0.8.2",
"tslib": "^1.9.3",
"underscore": "^1.9.1",
"ws": "^6.1.0"
},

The node never worked

Sorry had to run out of town. I may need you to console.log(node.watch) at line 335 and see what it spits out. You’ll need to hack the code then restart nodered and watch the nodered output.

This is a strange one to debug but I’m confident we’ll get to the bottom of it for sure.

Here is the code snippet and here the output...
console.log("---- START OF WATCH LOG ----");
console.log("---- Calling console.log(node.watch) ----");
console.log(node.watch);
console.log("---- Done calling console.log(node.watch) ----");

  console.log('Calling node.watch.on("socket", socket => {})');
  node.watch.on("socket", socket => {});
  console.log('Calling node.watch.on("error", err => {})');  **// NEVER GETS HERE** 

---- START OF WATCH LOG ----
---- Calling console.log(node.watch) ----
Promise { }
---- Done calling console.log(node.watch) ----
Calling node.watch.on("socket", socket => {})
(node:22096) UnhandledPromiseRejectionWarning: TypeError: node.watch.on is not a function
at KubernetesClientWatchNode.node.startWatch (/home/ubuntu/.node-red/node_modules/node-red-contrib-kubernetes-client/src/index.js:342:18)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
(Use node --trace-warnings ... to show where the warning was created)
(node:22096) 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(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:22096) [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.
13 Jun 14:33:53 - [info] [kubernetes-client-watch:PODS Watch] watching https://onapcontrol1ext:6443/api/v1/pods from resourceVersion: 762982

Ok that helps a bit. Give me a minute to dig through the library code and see what I discover.

Ok, sure enough they changed the api with a patch release :( I’ll pin the version down tighter but as a test can you try to add await to line 200 and see what you get?

node.watch = await watch.watch(

That worked. Thanks!

Nice! I’ll keep this open until I snap a new release.

I’m generally interested in understanding use-cases that people are implementing with it. Mind sharing what you intend to implement?

Fixed here: 5b06456