Closed meronogbai closed 2 months ago
Not sure why this is happening as I'm not too familiar with node or python but seems like a localized issue.
Can you check the logs or thrown exceptions to find out why the requests are timing out?
Also there are community made node and python wrappers available, can you see if those work for you: https://github.com/jikan-me/jikan-rest?tab=readme-ov-file#wrappers
@irfan-dahir I tried the jikan4 wrapper and it didn't work either.
Logs for node code snippet:
❯ node ./test.js
node:internal/deps/undici/undici:11372
Error.captureStackTrace(err, this);
^
TypeError: fetch failed
at Object.fetch (node:internal/deps/undici/undici:11372:11)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
cause: _ConnectTimeoutError: Connect Timeout Error
at onConnectTimeout (node:internal/deps/undici/undici:6616:28)
at node:internal/deps/undici/undici:6574:50
at Immediate._onImmediate (node:internal/deps/undici/undici:6605:13)
at process.processImmediate (node:internal/timers:476:21) {
code: 'UND_ERR_CONNECT_TIMEOUT'
}
}
Node.js v18.18.2
The python snippet just hangs indefinitely...
but seems like a localized issue
That's interesting. Can you tell me more?
Is your node/python on a separate environment (VPS, separate device, VM, WSL, etc)? If so, can you check if that environment has a working internet connection by trying out a curl command or perhaps pinging some other site or API?
Also, is this behavior consistent or just happening sometimes?
Is your node/python on a separate environment (VPS, separate device, VM, WSL, etc)? If so, can you check if that environment has a working internet connection by trying out a curl command or perhaps pinging some other site or API?
This could likely be due to firewall as well, so please look into that too
Nah it's all on my machine and it happens all the time.
https://github.com/jikan-me/jikan-rest/assets/22526062/a0237a77-4e47-48cf-b8f0-423fb7385941
It times out when I call the api inside node, and hangs when I call it via python and even wget. It doesn't time out when I run it inside the browser (using js), postman or curl.
contents of test.js
fetch('https://api.jikan.moe/v4/anime/20/full').then(console.log);
Unfortunately, due to my lack of familiarity with Python or Node, I'm unable to understand why this might be happening. Perhaps someone can chime in if they know what's wrong here.
Meanwhile, can you try out some other API so we can confirm whether this issue is directly related to Jikan or could be some code/environment-related factor?
No worries!
I tried using a different api and it doesn't have this issue.
fetch('https://cat-fact.herokuapp.com/facts')
.then((response) => response.json())
.then(console.log);
@meronogbai I was looking into the error thrown here:
code: 'UND_ERR_CONNECT_TIMEOUT'
Which led me to this: https://undici.nodejs.org/#/?id=network-address-family-autoselection
Someone posted a solution to this here: https://stackoverflow.com/a/76512104
Can you try and see if it works?
Yo that's an awesome clue
For posterity, I fixed this by running node --enable-network-family-autoselection ./test.js
instead of node test.js
.
Is there an existing issue for this?
Current Behavior
Connecting to api.jikan.moe keeps timing out in node and python runtimes.
Python example:
Node.js example
Weirdly enough, it works in postman, but not when I run this inside node or python. What could be the issue here?
Expected Behavior
I expected this api to work when I call it from node or python.
Steps To Reproduce
Copy the code snippets above and run them in your machine.
Environment
Anything else?
No response