deno
deno copied to clipboard
Node compat doesn’t work for node-yahoo-finance2
Deno: 1.37.1
import yf from 'npm:yahoo-finance2';
console.log(await yf.quoteSummary('AAPL'));
Crashes with the following:
error: Uncaught Error: Errors { invalid_mapping, disallowed_character }
at Object.toASCII (node:punycode:5:14)
at file:///Users/sergees/Library/Caches/deno/npm/registry.npmjs.org/psl/1.9.0/index.js:44:34
at Array.reduce (<anonymous>)
at Object.internals.findRule (file:///Users/sergees/Library/Caches/deno/npm/registry.npmjs.org/psl/1.9.0/index.js:41:26)
at Object.exports.parse (file:///Users/sergees/Library/Caches/deno/npm/registry.npmjs.org/psl/1.9.0/index.js:198:24)
at Object.exports.get (file:///Users/sergees/Library/Caches/deno/npm/registry.npmjs.org/psl/1.9.0/index.js:258:18)
at Object.getPublicSuffix (file:///Users/sergees/Library/Caches/deno/npm/registry.npmjs.org/tough-cookie/4.1.3/lib/pubsuffix-psl.js:70:14)
at permuteDomain (file:///Users/sergees/Library/Caches/deno/npm/registry.npmjs.org/tough-cookie/4.1.3/lib/permuteDomain.js:38:28)
at MemoryCookieStore.findCookies (file:///Users/sergees/Library/Caches/deno/npm/registry.npmjs.org/tough-cookie/4.1.3/lib/memstore.js:99:21)
at MemoryCookieStore.findCookies (file:///Users/sergees/Library/Caches/deno/npm/registry.npmjs.org/universalify/0.2.0/index.js:5:67)
Looks like an issue with deno according to https://github.com/gadicc/node-yahoo-finance2/issues/685
Same issue for Node's PSL library (https://www.npmjs.com/package/psl).
error: Uncaught Error: Errors { invalid_mapping, disallowed_character }
at Object.toASCII (node:punycode:5:14)
at file:///.../Caches/deno/npm/registry.npmjs.org/psl/1.9.0/index.js:44:34
at Array.reduce (<anonymous>)
at Object.internals.findRule (.../Caches/deno/npm/registry.npmjs.org/psl/1.9.0/index.js:41:26)
at Object.exports.parse (.../Caches/deno/npm/registry.npmjs.org/psl/1.9.0/index.js:198:24)
at Object.exports.get (.../Caches/deno/npm/registry.npmjs.org/psl/1.9.0/index.js:258:18)
...
Hey, I'm facing the same issue, any luck on resolving it?
@DDushkin I gave up immediately and haven’t tried it since then
@DDushkin I gave up immediately and haven’t tried it since then
I see, maybe you found a different solution or library for getting quotes?
Did a little digging and Deno stumbles when passing the string in this line to toASCII
https://github.com/lupomontero/psl/blob/a789d0381c886da02eb8594da0761860657c08ba/data/rules.json#L929
"个��.hk"
Minimal reproduction:
import PunyCode from "node:punycode";
console.log(PunyCode.toASCII("个��.hk"));
// Node logs: xn--ciq6844ba.hk
@DDushkin Yes I’m using alphavantage via their REST API
Just came across this issue in the psl
issue tracker. Looks like this is an encoding bug in the actual data.json
file https://github.com/lupomontero/psl/issues/310
The official one from https://publicsuffix.org/list/public_suffix_list.dat doesn't have this issue.
The original issue reported here should be fixed (by https://github.com/denoland/deno/pull/22847). I've confirmed the snippet in the initial report works correctly now.
Let us know if you continue to have issues with this!