yagop / node-telegram-bot-api

Telegram Bot API for NodeJS
MIT License
8.34k stars 1.52k forks source link

Failed to sendMessage() with nodejs 20 and ubuntu 22 #1156

Closed jinsankim closed 9 months ago

jinsankim commented 9 months ago

Bug Report

Failed to sendMessage() with nodejs 20 and ubuntu 22.

Please note that I've succeeded to 'sendMessage()`

I am using the latest version of the library.

Expected Behavior

send a message successfully.

Actual Behavior

failed to send a message with an exceptions.

Steps to reproduce the Behavior

code

import TelegramBot from 'node-telegram-bot-api'

const BOT_TOKEN = 'MY_TELEGRAM_BOT_TOKEN'
const CHAT_ID = MY_CHAT_ID

async function main() {
  const bot = new TelegramBot(BOT_TOKEN, { polling: true })
  bot.on('polling_error', error => {
    console.error('[Error][ArbitrageBot][PollingError] error:', error)
  })

  await bot.sendMessage(CHAT_ID, 'hello?')
  console.info('done')
}

main().catch(e => {
  console.error('[Error] Unhandled Exception:', e)
  console.info('[Error] Unhandled Exception:', e)
  process.exit(1)
})

error

[Error][ArbitrageBot][PollingError] error: RequestError: AggregateError
    at new RequestError (/home/my-project/node_modules/request-promise-core/lib/errors.js:14:15)
    at Request.plumbing.callback (/home/my-project/node_modules/request-promise-core/lib/plumbing.js:87:29)
    at Request.RP$callback [as _callback] (/home/my-project/node_modules/request-promise-core/lib/plumbing.js:46:31)
    at self.callback (/home/my-project/node_modules/@cypress/request/request.js:183:22)
    at Request.emit (node:events:514:28)
    at Request.onRequestError (/home/my-project/node_modules/@cypress/request/request.js:869:8)
    at ClientRequest.emit (node:events:514:28)
    at TLSSocket.socketErrorListener (node:_http_client:495:9)
    at TLSSocket.emit (node:events:514:28)
    at emitErrorNT (node:internal/streams/destroy:151:8)
    at emitErrorCloseNT (node:internal/streams/destroy:116:3)
    at processTicksAndRejections (node:internal/process/task_queues:82:21)
    at runNextTicks (node:internal/process/task_queues:64:3)
    at listOnTimeout (node:internal/timers:540:9)
    at processTimers (node:internal/timers:514:7) {
  code: 'EFATAL'
}
[Error] Unhandled Exception: RequestError: AggregateError
    at new RequestError (/home/my-project/node_modules/request-promise-core/lib/errors.js:14:15)
    at Request.plumbing.callback (/home/my-project/node_modules/request-promise-core/lib/plumbing.js:87:29)
    at Request.RP$callback [as _callback] (/home/my-project/node_modules/request-promise-core/lib/plumbing.js:46:31)
    at self.callback (/home/my-project/node_modules/@cypress/request/request.js:183:22)
    at Request.emit (node:events:514:28)
    at Request.onRequestError (/home/my-project/node_modules/@cypress/request/request.js:869:8)
    at ClientRequest.emit (node:events:514:28)
    at TLSSocket.socketErrorListener (node:_http_client:495:9)
    at TLSSocket.emit (node:events:514:28)
    at emitErrorNT (node:internal/streams/destroy:151:8)
    at emitErrorCloseNT (node:internal/streams/destroy:116:3)
    at processTicksAndRejections (node:internal/process/task_queues:82:21) {
  code: 'EFATAL'
}
[Error] Unhandled Exception: RequestError: AggregateError
    at new RequestError (/home/my-project/node_modules/request-promise-core/lib/errors.js:14:15)
    at Request.plumbing.callback (/home/my-project/node_modules/request-promise-core/lib/plumbing.js:87:29)
    at Request.RP$callback [as _callback] (/home/my-project/node_modules/request-promise-core/lib/plumbing.js:46:31)
    at self.callback (/home/my-project/node_modules/@cypress/request/request.js:183:22)
    at Request.emit (node:events:514:28)
    at Request.onRequestError (/home/my-project/node_modules/@cypress/request/request.js:869:8)
    at ClientRequest.emit (node:events:514:28)
    at TLSSocket.socketErrorListener (node:_http_client:495:9)
    at TLSSocket.emit (node:events:514:28)
    at emitErrorNT (node:internal/streams/destroy:151:8)
    at emitErrorCloseNT (node:internal/streams/destroy:116:3)
    at processTicksAndRejections (node:internal/process/task_queues:82:21) {
  code: 'EFATAL'
}
paulorlima9 commented 9 months ago

Hello, how did you solve the error?