gramjs
gramjs copied to clipboard
"Random" error on sendMessage
Hi,
Sometimes, I'm trying to send a message with an account with this API using sendMessage, and it "randomly" fails sometimes with this error : update.message._finishInit is not a function
Note that this fail will make the script crash if not catched. By the way, it's not really random, it seems that it's bound to spam activities - but the main problem is that the lib isn't handling properly the error.
While I'm here, some little improvements for this lib that is already great :
- Ability to close a session
- More consistency for the error messages, for example when trying to join a group where I'm banned, I'll get 'CHANNEL_PRIVATE' which is poorly documented in the official doc.
are you using client.sendMessage or new SendMessage? also can you show full traceback.
I'm using client.sendMessage
- the fact that I'm catching this error and that it happens randomly makes hard to get a full traceback, I'll try to provide one but not 100% sure I'll succeed.
Hey, little update : I'm still trying to get the full traceback, should get it today / tomorrow.
While I'm here, little error that I detected :
[2022-01-17T15:44:01.881Z] [ERROR] - [TypeError: this._sendArray is not a function]
This happens when a lot of sessions are open on the same script, maybe a memory leak. Not sure it's something that can be improved in the lib, but the error could be clearer. Could you also share me a BSC address to send a tip to the creators of this lib?
Hi,
Got another use case
TypeError: message._finishInit is not a function
at _DialogsIter._loadNextChunk (/app/node_modules/.pnpm/[email protected]/node_modules/telegram/client/dialogs.js:89:25)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Object.next (/app/node_modules/.pnpm/[email protected]/node_modules/telegram/requestIter.js:56:39)
at async _DialogsIter.collect (/app/node_modules/.pnpm/[email protected]/node_modules/telegram/requestIter.js:88:57)
at async Object.getDialogs (/app/node_modules/.pnpm/[email protected]/node_modules/telegram/client/dialogs.js:165:13)
Context: i previously got a RPC timeout when downloading a file. Now, each time i'm getting dialogs using getDialogs, i got this error. BUT, with a try/catch my code continue (i got all dialogs as expected dispite this error).
Messages not having _finishInit are kind of this :
{
CONSTRUCTOR_ID: xxxxxxx,
SUBCLASS_OF_ID: xxxxxxx,
className: 'MessageEmpty',
classType: 'constructor',
flags: 1,
id: 1,
peerId: {
CONSTRUCTOR_ID: xxxxxx,
SUBCLASS_OF_ID: xxxxxx,
className: 'PeerChannel',
classType: 'constructor',
channelId: Integer { value: xxxxxxxn }
}
}