bergehurra
bergehurra16mo ago

`Uncaught TypeError: encode is not a function` when using npm module `@kubernetes-client/node`

I'm trying to use a particular call in the npm module @kubernetes/client-node from deno, but I'm getting a TypeError, and I'm not sure how to debug it:
0 berge@varmeskapet:~/deno/typeerror> deno run --allow-read --allow-env --allow-sys --allow-run main.ts
error: Uncaught TypeError: encode is not a function
at encodeStringifiedCustom (node:querystring:641:12)
at Object.stringify (node:querystring:683:22)
at Querystring.stringify (file:///home/berge/.cache/deno/npm/registry.npmjs.org/request/2.88.2/lib/querystring.js:26:29)
at Request.qs (file:///home/berge/.cache/deno/npm/registry.npmjs.org/request/2.88.2/request.js:1223:21)
at Request.init (file:///home/berge/.cache/deno/npm/registry.npmjs.org/request/2.88.2/request.js:344:10)
at new Request (file:///home/berge/.cache/deno/npm/registry.npmjs.org/request/2.88.2/request.js:127:8)
at DefaultRequest.request [as requestImpl] (file:///home/berge/.cache/deno/npm/registry.npmjs.org/request/2.88.2/index.js:53:10)
at DefaultRequest.webRequest (file:///home/berge/.cache/deno/npm/registry.npmjs.org/@kubernetes/client-node/0.18.1/dist/watch.js:15:26)
at Watch.watch (file:///home/berge/.cache/deno/npm/registry.npmjs.org/@kubernetes/client-node/0.18.1/dist/watch.js:75:32)
at async file:///home/berge/deno/typeerror/main.ts:7:1
0 berge@varmeskapet:~/deno/typeerror> deno run --allow-read --allow-env --allow-sys --allow-run main.ts
error: Uncaught TypeError: encode is not a function
at encodeStringifiedCustom (node:querystring:641:12)
at Object.stringify (node:querystring:683:22)
at Querystring.stringify (file:///home/berge/.cache/deno/npm/registry.npmjs.org/request/2.88.2/lib/querystring.js:26:29)
at Request.qs (file:///home/berge/.cache/deno/npm/registry.npmjs.org/request/2.88.2/request.js:1223:21)
at Request.init (file:///home/berge/.cache/deno/npm/registry.npmjs.org/request/2.88.2/request.js:344:10)
at new Request (file:///home/berge/.cache/deno/npm/registry.npmjs.org/request/2.88.2/request.js:127:8)
at DefaultRequest.request [as requestImpl] (file:///home/berge/.cache/deno/npm/registry.npmjs.org/request/2.88.2/index.js:53:10)
at DefaultRequest.webRequest (file:///home/berge/.cache/deno/npm/registry.npmjs.org/@kubernetes/client-node/0.18.1/dist/watch.js:15:26)
at Watch.watch (file:///home/berge/.cache/deno/npm/registry.npmjs.org/@kubernetes/client-node/0.18.1/dist/watch.js:75:32)
at async file:///home/berge/deno/typeerror/main.ts:7:1
Code at https://gist.github.com/berge/379b25d2e780ccddf2734773ef6b6bdc. I'm unsure if this is a bug in Deno's nodejs compatibility layer, or something else. (The program works fine in nodejs with typescript.) What's a good place to start investigating? Edit: Deno version:
0 berge@varmeskapet:~/deno/typeerror> deno --version
deno 1.36.1 (release, x86_64-unknown-linux-gnu)
v8 11.6.189.12
typescript 5.1.6
0 berge@varmeskapet:~/deno/typeerror> deno --version
deno 1.36.1 (release, x86_64-unknown-linux-gnu)
v8 11.6.189.12
typescript 5.1.6
11 Replies
tr1ckydev
tr1ckydev16mo ago
Deno
Node.js compatibility mode | Manual | Deno
Starting with v1.15 Deno provides Node compatiblity mode that makes it possible to run a subset of programs authored for Node.js directly in Deno. Compatiblity mode can be activated by passing `--com
tr1ckydev
tr1ckydev16mo ago
try compat flag
bergehurra
bergehurraOP15mo ago
--compat was removed in Deno 1.25.2, since the npm: style import was introduced. I don't think this is an import problem as such, it kind of looks like some sort of implementation error in the querystring emulation layer in Deno, right? For what it's worth, this appears to be fixed as of Deno 1.36.3.
hpx7
hpx712mo ago
is this fixed for you? i'm still running into it with Deno 1.39.0
Candeia
Candeia11mo ago
Same here
Antonio Sampaio
Antonio Sampaio11mo ago
have you guys seen the code on the stack trace? I'll try to look at it when I go to the PC Also.. what about tô use the deno.land alternative??? I use and love it
bartlomieju
bartlomieju11mo ago
This is getting fixed in 1.39.2
Antonio Sampaio
Antonio Sampaio11mo ago
<:party_deno:1035517691517218847>
Candeia
Candeia11mo ago
I can confirm that was fixed!
hpx7
hpx711mo ago
is anyone else running into cert issues with @kubernetes/client-node and Deno? I can only get it to run with --unsafely-ignore-certificate-errors, otherwise I run into this issue: https://github.com/denoland/deno/issues/2301
Candeia
Candeia11mo ago
Yes you need to since kubernetes uses self-signed certs @hpx7