gramjs: Error: Cannot send requests while disconnected. You need to call .connect()

My app work fine, but sometimes it fall down with error:

Error: Cannot send requests while disconnected. You need to call .connect(), which begin run in endless cycle

then script die with another error:

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory

so my question is:

what is the bug with this:

Error: Cannot send requests while disconnected. You need to call .connect() ?

Why this sometimes run in endless cycle and never end? This definitely need to be fixed.

This bug was in version 2.5.* and now in 2.6.13 it has too.

Full error look like this:

Error: Cannot send requests while disconnected. You need to call .connect()
    at MTProtoSender.send (/code/node_modules/telegram/network/MTProtoSender.js:197:19)
    at Object.invoke (/code/node_modules/telegram/client/users.js:31:36)
    at async TelegramClient.getDC (/code/node_modules/telegram/client/TelegramClient.js:1120:28)
    at async TelegramClient._connectSender (/code/node_modules/telegram/client/telegramBaseClient.js:200:20)
    at async TelegramClient._borrowExportedSender (/code/node_modules/telegram/client/telegramBaseClient.js:243:22)

p.s.: right before this error it show this:

Error: Disconnect 
 at /code/node_modules/telegram/extensions/MessagePacker.js:106:33 
 at Array.forEach (<anonymous>) 
 at MessagePacker.rejectAll (/code/node_modules/telegram/extensions/MessagePacker.js:105:29) 
 at MTProtoSender._disconnect (/code/node_modules/telegram/network/MTProtoSender.js:247:25) 
 at MTProtoSender.disconnect (/code/node_modules/telegram/network/MTProtoSender.js:168:20) 
 at MTProtoSender._reconnect (/code/node_modules/telegram/network/MTProtoSender.js:728:24) 
 at /code/node_modules/telegram/network/MTProtoSender.js:721:22

Thanks.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 31 (8 by maintainers)

Most upvoted comments

If there is an error during the authentication process there is an “onError” callback that you can use to either continue the authentication process or to exit.

this may happen during client.connect(), but not during authentication process. So this is another situation here.