Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error When launch #1981

Open
adiwirak opened this issue Apr 20, 2024 · 6 comments
Open

Error When launch #1981

adiwirak opened this issue Apr 20, 2024 · 6 comments

Comments

@adiwirak
Copy link

Context

  • Telegraf.js Version: 4.16.3
  • Node.js Version: 20.11.0
  • Operating System: Linux

Error Message and Logs (export DEBUG='telegraf:*')

2/logs/42-error.log last 500 lines:
558|42     | FetchError: request to https://api.telegram.org/bot6342659310:[REDACTED]/getMe failed, reason: 
558|42     |     at ClientRequest.<anonymous> (/home/spi/BankSatuExt/node_modules/telegraf/node_modules/node-fetch/lib/index.js:1501:11)
558|42     |     at ClientRequest.emit (node:events:518:28)
558|42     |     at TLSSocket.socketErrorListener (node:_http_client:495:9)
558|42     |     at TLSSocket.emit (node:events:518:28)
558|42     |     at emitErrorNT (node:internal/streams/destroy:169:8)
558|42     |     at emitErrorCloseNT (node:internal/streams/destroy:128:3)
558|42     |     at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
558|42     |   type: 'system',
558|42     |   errno: 'ETIMEDOUT',
558|42     |   code: 'ETIMEDOUT'
558|42     | }

I think, this is a network/ISP problem. But when I tried to hit

curl https://api.telegram.org/bot63****10:xxxccxx/getUpdates

it get respon, ok.

{"ok":true,"result":[]}

So, what do you think? Is it just a network problem, or is there another problem?

So is there a solution?

@sinh117801
Copy link

I'm facing the same issue on my node project. But when I try some dummy connection with Bun, it works.

@adiwirak
Copy link
Author

I'm facing the same issue on my node project. But when I try some dummy connection with Bun, it works.

What is Bun? How to implement it

@sinh117801
Copy link

https://bun.sh another js runtime

import { Telegraf, Telegram } from "telegraf";
import { message } from "telegraf/filters";

const bot = new Telegraf('your token');

bot.start((ctx) => {
    console.log('==========')
    const message = ctx.update;
    console.log(message)
    console.log(message.message.entities)

    // convert Unix time to Date time
    console.log({ date: new Date(message.message.date * 1000) })
    console.log('==========')
})

bot.launch();
console.log('Bot is running...');

@kubeplusplus
Copy link

telegraf is using old version of node-fetch (v2.7.0), so if you got the error ETIMEDOUT like me, downgrade to v18 will make telegraf work again

@billyadelphia
Copy link

telegraf is using old version of node-fetch (v2.7.0), so if you got the error ETIMEDOUT like me, downgrade to v18 will make telegraf work again

Got the same issue ..
it's looks like I have to change to another package ..
The team need to support node 20, new project will use new LTS version

@MKRhere
Copy link
Member

MKRhere commented Jun 2, 2024

@kubeplusplus node-fetch v3 only supports ESM packages, and Telegraf supports both CJS and ESM projects.
@billyadelphia The issue isn't with Telegraf or node-fetch, but a change to how Node v20 orders ipv4 and ipv6 addresses.

Node has to implement this:
nodejs/node#48145

Consider this fix?
nodejs/node#47822 (comment)

Using the latest version of Bun instead of Node might also work. If nothing else, downgrading to Node v18 until they implement/fix RFC 8305 (in v22, potentially backported to v20 LTS?) is an idea.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants