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

Unhandled rejection #104

Closed
softforseeker opened this issue Sep 22, 2020 · 13 comments
Closed

Unhandled rejection #104

softforseeker opened this issue Sep 22, 2020 · 13 comments

Comments

@softforseeker
Copy link

Version: 4.0.1
When i call messages.getBotCallbackAnswer method i got the following error instead of response:

RangeError: Offset is outside the bounds of the DataView at DataView.getUint32 (<anonymous>) at Deserializer.uint32 (C:\Users\User\project\node_modules\@mtproto\core\src\tl\deserializer\index.cjs:22:33) at Deserializer.long (C:\Users\User\project\node_modules\@mtproto\core\src\tl\deserializer\index.cjs:36:23) at long (C:\Users\User\project\node_modules\@mtproto\core\src\tl\parser\index.cjs:5:33) at result._ (C:\Users\User\project\node_modules\@mtproto\core\src\tl\parser\index.cjs:208:17) at mt_message (C:\Users\User\project\node_modules\@mtproto\core\src\tl\parser\index.cjs:11:51) at vector (C:\Users\User\project\node_modules\@mtproto\core\src\tl\parser\index.cjs:21:17) at result._ (C:\Users\User\project\node_modules\@mtproto\core\src\tl\parser\index.cjs:203:19) at predicate (C:\Users\User\project\node_modules\@mtproto\core\src\tl\parser\index.cjs:29:12) at module.exports (C:\Users\User\project\node_modules\@mtproto\core\src\tl\parser\index.cjs:36:10)

It may be related with telegram updates received in this time.

@alik0211
Copy link
Owner

Show me your code so I can repeat the error.

@softforseeker
Copy link
Author

softforseeker commented Sep 22, 2020

By the security reason i can't provide full code, but now i work on write code what can repeat this error. I hope i can provide this code as fast as possible.
Forgot to mention that this error appears after the second messages.getBotCallbackAnswer method call

P.S. Some lines of code may be numbered incorrectly. in some places the function console.log is called

@alik0211
Copy link
Owner

Just show what parameters you use to call the messages.getBotCallbackAnswer method.

@softforseeker
Copy link
Author

softforseeker commented Sep 22, 2020

{
	flags: 1,
	peer: {
		'_': 'inputPeerUser',
		user_id: config.bot.id,
		access_hash: config.bot.hash
	},
	msg_id: parseInt(msg_id),
	data: Array.from(button_data)
}

@softforseeker
Copy link
Author

I checked it again, and may describe problem in details.
Problem not in the method message.getBotCallbackAnswer
I got the predicate id that is causing the problem and it turned out to be a predicate 'userStatusOnline' (ID: 3988339017)
After commenting lines 705 - 706 in /src/tl/builder/index.cjs the problem is gone.

'userStatusOnline': (params) => { int(3988339017); int(params.expires); }

@softforseeker
Copy link
Author

Predicate provided before is correct, because error repeats with another one.
Actual error log:

RangeError: Offset is outside the bounds of the DataView at DataView.getUint32 (<anonymous>) at Deserializer.uint32 (C:\Users\user\project\node_modules\@mtproto\core\src\tl\deserializer\index.cjs:17:34) at Deserializer.long (C:\Users\user\project\node_modules\@mtproto\core\src\tl\deserializer\index.cjs:29:21) at long (C:\Users\user\project\node_modules\@mtproto\core\src\tl\parser\index.cjs:5:33) at result._ (C:\Users\user\project\node_modules\@mtproto\core\src\tl\parser\index.cjs:208:17) at mt_message (C:\Users\user\project\node_modules\@mtproto\core\src\tl\parser\index.cjs:11:51) at vector (C:\Users\user\project\node_modules\@mtproto\core\src\tl\parser\index.cjs:21:17) at result._ (C:\Users\user\project\node_modules\@mtproto\core\src\tl\parser\index.cjs:203:19) at predicate (C:\Users\user\project\node_modules\@mtproto\core\src\tl\parser\index.cjs:29:12) at module.exports (C:\Users\user\project\node_modules\@mtproto\core\src\tl\parser\index.cjs:36:10)

Last five predicates before error throwing:
3973537164 (userProfilePhoto)
3162490573 (fileLocationToBeDeprecated)
3162490573
2474924225 (user)
3988339017 (userStatusOnline)

Seems like updates object

Possible solutions:

  1. Check dataView has next bytes here: https://github.com/alik0211/mtproto-core/blob/master/src/tl/deserializer/index.js#L28-L35

  2. From the logs, we can understand that possible the matter is in mt_msg_container predicate. Deserializer can't resolve msg_id for one of msg in this predicate.

@softforseeker
Copy link
Author

softforseeker commented Sep 30, 2020

After one more debugging i can provide more problem details:

  1. Error throwing only when message is gzip_packed and function mt_message called. It's not linked with other predicates.
  2. In case with error, vector() result always is empty array (previously int() call returns 0)

I think, problem in this lines:

const mt_gzip_packed = () => { deserializer = new Deserializer(pako.inflate(bytes()).buffer, true); return predicate(); };
because in this case deserializer variable is overrided.

@alik0211
Copy link
Owner

Excellent research, @softforseeker

Thank you very much!

This issue is fixed in version 5.0.0 - https://t.me/mtproto_core/23

@Mongolfyer
Copy link

Hello there. Since yesterday I have a similar problem everytime when I use a call with any value. For example code from example:

class API {
	constructor() {
		this.mtproto = new MTProto({
			api_id: config.api_id,
			api_hash: config.api_hash,
			storageOptions: {
				path: path.resolve(__dirname, `.data/${config.id}.json`),
			},
		});
	}
	async call(method, params, options = {}) {
		try {
			const result = await this.mtproto.call(method, params, options);
			return result;
		} catch (error) {
			console.log(config.id, `${method} error:`, error);
			const { error_code, error_message } = error;
			if (error_code === 420) {
				let seconds = Number(error_message.split('FLOOD_WAIT_')[1]);
				if (!seconds) seconds = Number(error_message.split('SLOWMODE_WAIT_')[1]);
				let ms = seconds * 1000;
				await sleep(ms);
				return this.call(method, params, options);
			}
			if (error_code === 303) {
				const [type, dcIdAsString] = error_message.split('_MIGRATE_');
				const dcId = Number(dcIdAsString);
				if (type === 'PHONE') {
					await this.mtproto.setDefaultDc(dcId);
				} else {
					Object.assign(options, { dcId });
				}
				return this.call(method, params, options);
			}
			return Promise.reject(error);
		}
	}
}

const api = new API();

async function getUser() {
  try {
    const user = await api.call('users.getFullUser', {
      id: {
        _: 'inputUserSelf',
      },
    });

    return user;
  } catch (error) {
    return null;
  }
}

let user;

(async () => {
  user = await getUser();
})();

Console logs:

Not found predicate with id: 168464312

Not found predicate with id: 3050349264

Not found predicate with id: 539933648

Not found predicate with id: 960050987

Not found predicate with id: 892481584

Not found predicate with id: 808663088

Not found predicate with id: 3491769632

Not found predicate with id: 3501772957

Not found predicate with id: 3502166202

Not found predicate with id: 3501248699

Not found predicate with id: 185

Not found predicate with id: 76318

Not found predicate with id: 1

Not found predicate with id: 1692164395

Not found predicate with id: 0

Not found predicate with id: 3747555843

Not found predicate with id: 1478877011

Not found predicate with id: 1639088239

Not found predicate with id: 2996303866

Not found predicate with id: 1522926040

Not found predicate with id: 2731421657

/rbd/pnpm-volume/cc9e2355-b003-40bc-8b59-bd5205d9b1ef/node_modules/@mtproto/core/src/tl/deserializer/index.js:25

const value = this.dataView.getInt32(this.offset, true);

                            ^

RangeError: Offset is outside the bounds of the DataView

at DataView.getInt32 (<anonymous>)

at Deserializer.int32 (/rbd/pnpm-volume/cc9e2355-b003-40bc-8b59-bd5205d9b1ef/node_modules/@mtproto/core/src/tl/deserializer/index.js:25:33)

at Deserializer.predicate (/rbd/pnpm-volume/cc9e2355-b003-40bc-8b59-bd5205d9b1ef/node_modules/@mtproto/core/src/tl/deserializer/index.js:112:21)

at Deserializer.vector (/rbd/pnpm-volume/cc9e2355-b003-40bc-8b59-bd5205d9b1ef/node_modules/@mtproto/core/src/tl/deserializer/index.js:89:22)

at Deserializer.module.exports (/rbd/pnpm-volume/cc9e2355-b003-40bc-8b59-bd5205d9b1ef/node_modules/@mtproto/core/src/tl/parser/index.js:1203:21)

at Deserializer.predicate (/rbd/pnpm-volume/cc9e2355-b003-40bc-8b59-bd5205d9b1ef/node_modules/@mtproto/core/src/tl/deserializer/index.js:121:15)

at RPC.handleEncryptedMessage (/rbd/pnpm-volume/cc9e2355-b003-40bc-8b59-bd5205d9b1ef/node_modules/@mtproto/core/src/rpc/index.js:449:38)

at processTicksAndRejections (node:internal/process/task_queues:96:5)

@HODOR72
Copy link

HODOR72 commented Aug 18, 2023

Hello there. Since yesterday I have a similar problem everytime when I use a call with any value. For example code from example:

class API {
	constructor() {
		this.mtproto = new MTProto({
			api_id: config.api_id,
			api_hash: config.api_hash,
			storageOptions: {
				path: path.resolve(__dirname, `.data/${config.id}.json`),
			},
		});
	}
	async call(method, params, options = {}) {
		try {
			const result = await this.mtproto.call(method, params, options);
			return result;
		} catch (error) {
			console.log(config.id, `${method} error:`, error);
			const { error_code, error_message } = error;
			if (error_code === 420) {
				let seconds = Number(error_message.split('FLOOD_WAIT_')[1]);
				if (!seconds) seconds = Number(error_message.split('SLOWMODE_WAIT_')[1]);
				let ms = seconds * 1000;
				await sleep(ms);
				return this.call(method, params, options);
			}
			if (error_code === 303) {
				const [type, dcIdAsString] = error_message.split('_MIGRATE_');
				const dcId = Number(dcIdAsString);
				if (type === 'PHONE') {
					await this.mtproto.setDefaultDc(dcId);
				} else {
					Object.assign(options, { dcId });
				}
				return this.call(method, params, options);
			}
			return Promise.reject(error);
		}
	}
}

const api = new API();

async function getUser() {
  try {
    const user = await api.call('users.getFullUser', {
      id: {
        _: 'inputUserSelf',
      },
    });

    return user;
  } catch (error) {
    return null;
  }
}

let user;

(async () => {
  user = await getUser();
})();

Console logs:

Not found predicate with id: 168464312
Not found predicate with id: 3050349264
Not found predicate with id: 539933648
Not found predicate with id: 960050987
Not found predicate with id: 892481584
Not found predicate with id: 808663088
Not found predicate with id: 3491769632
Not found predicate with id: 3501772957
Not found predicate with id: 3502166202
Not found predicate with id: 3501248699
Not found predicate with id: 185
Not found predicate with id: 76318
Not found predicate with id: 1
Not found predicate with id: 1692164395
Not found predicate with id: 0
Not found predicate with id: 3747555843
Not found predicate with id: 1478877011
Not found predicate with id: 1639088239
Not found predicate with id: 2996303866
Not found predicate with id: 1522926040
Not found predicate with id: 2731421657
/rbd/pnpm-volume/cc9e2355-b003-40bc-8b59-bd5205d9b1ef/node_modules/@mtproto/core/src/tl/deserializer/index.js:25

const value = this.dataView.getInt32(this.offset, true);

                            ^

RangeError: Offset is outside the bounds of the DataView

at DataView.getInt32 (<anonymous>)

at Deserializer.int32 (/rbd/pnpm-volume/cc9e2355-b003-40bc-8b59-bd5205d9b1ef/node_modules/@mtproto/core/src/tl/deserializer/index.js:25:33)

at Deserializer.predicate (/rbd/pnpm-volume/cc9e2355-b003-40bc-8b59-bd5205d9b1ef/node_modules/@mtproto/core/src/tl/deserializer/index.js:112:21)

at Deserializer.vector (/rbd/pnpm-volume/cc9e2355-b003-40bc-8b59-bd5205d9b1ef/node_modules/@mtproto/core/src/tl/deserializer/index.js:89:22)

at Deserializer.module.exports (/rbd/pnpm-volume/cc9e2355-b003-40bc-8b59-bd5205d9b1ef/node_modules/@mtproto/core/src/tl/parser/index.js:1203:21)

at Deserializer.predicate (/rbd/pnpm-volume/cc9e2355-b003-40bc-8b59-bd5205d9b1ef/node_modules/@mtproto/core/src/tl/deserializer/index.js:121:15)

at RPC.handleEncryptedMessage (/rbd/pnpm-volume/cc9e2355-b003-40bc-8b59-bd5205d9b1ef/node_modules/@mtproto/core/src/rpc/index.js:449:38)

at processTicksAndRejections (node:internal/process/task_queues:96:5)

I faced the same problem, did you manage to solve it?

@Mongolfyer
Copy link

I faced the same problem, did you manage to solve it?

I created a new project and ran it on a clean server. Now it's fine, but I don't know how long it will be fine. This does not look like a good way, but it is suitable as a temporary solution.

@furkan-demirci
Copy link

Hello there. Since yesterday I have a similar problem everytime when I use a call with any value. For example code from example:

class API {
	constructor() {
		this.mtproto = new MTProto({
			api_id: config.api_id,
			api_hash: config.api_hash,
			storageOptions: {
				path: path.resolve(__dirname, `.data/${config.id}.json`),
			},
		});
	}
	async call(method, params, options = {}) {
		try {
			const result = await this.mtproto.call(method, params, options);
			return result;
		} catch (error) {
			console.log(config.id, `${method} error:`, error);
			const { error_code, error_message } = error;
			if (error_code === 420) {
				let seconds = Number(error_message.split('FLOOD_WAIT_')[1]);
				if (!seconds) seconds = Number(error_message.split('SLOWMODE_WAIT_')[1]);
				let ms = seconds * 1000;
				await sleep(ms);
				return this.call(method, params, options);
			}
			if (error_code === 303) {
				const [type, dcIdAsString] = error_message.split('_MIGRATE_');
				const dcId = Number(dcIdAsString);
				if (type === 'PHONE') {
					await this.mtproto.setDefaultDc(dcId);
				} else {
					Object.assign(options, { dcId });
				}
				return this.call(method, params, options);
			}
			return Promise.reject(error);
		}
	}
}

const api = new API();

async function getUser() {
  try {
    const user = await api.call('users.getFullUser', {
      id: {
        _: 'inputUserSelf',
      },
    });

    return user;
  } catch (error) {
    return null;
  }
}

let user;

(async () => {
  user = await getUser();
})();

Console logs:

Not found predicate with id: 168464312
Not found predicate with id: 3050349264
Not found predicate with id: 539933648
Not found predicate with id: 960050987
Not found predicate with id: 892481584
Not found predicate with id: 808663088
Not found predicate with id: 3491769632
Not found predicate with id: 3501772957
Not found predicate with id: 3502166202
Not found predicate with id: 3501248699
Not found predicate with id: 185
Not found predicate with id: 76318
Not found predicate with id: 1
Not found predicate with id: 1692164395
Not found predicate with id: 0
Not found predicate with id: 3747555843
Not found predicate with id: 1478877011
Not found predicate with id: 1639088239
Not found predicate with id: 2996303866
Not found predicate with id: 1522926040
Not found predicate with id: 2731421657
/rbd/pnpm-volume/cc9e2355-b003-40bc-8b59-bd5205d9b1ef/node_modules/@mtproto/core/src/tl/deserializer/index.js:25

const value = this.dataView.getInt32(this.offset, true);

                            ^

RangeError: Offset is outside the bounds of the DataView

at DataView.getInt32 (<anonymous>)

at Deserializer.int32 (/rbd/pnpm-volume/cc9e2355-b003-40bc-8b59-bd5205d9b1ef/node_modules/@mtproto/core/src/tl/deserializer/index.js:25:33)

at Deserializer.predicate (/rbd/pnpm-volume/cc9e2355-b003-40bc-8b59-bd5205d9b1ef/node_modules/@mtproto/core/src/tl/deserializer/index.js:112:21)

at Deserializer.vector (/rbd/pnpm-volume/cc9e2355-b003-40bc-8b59-bd5205d9b1ef/node_modules/@mtproto/core/src/tl/deserializer/index.js:89:22)

at Deserializer.module.exports (/rbd/pnpm-volume/cc9e2355-b003-40bc-8b59-bd5205d9b1ef/node_modules/@mtproto/core/src/tl/parser/index.js:1203:21)

at Deserializer.predicate (/rbd/pnpm-volume/cc9e2355-b003-40bc-8b59-bd5205d9b1ef/node_modules/@mtproto/core/src/tl/deserializer/index.js:121:15)

at RPC.handleEncryptedMessage (/rbd/pnpm-volume/cc9e2355-b003-40bc-8b59-bd5205d9b1ef/node_modules/@mtproto/core/src/rpc/index.js:449:38)

at processTicksAndRejections (node:internal/process/task_queues:96:5)

I've got exactly the same issue. Any way to solve this issue? Clean project/server does not work for me.

@alexvais
Copy link

Hello there. Since yesterday I have a similar problem everytime when I use a call with any value. For example code from example:

class API {
	constructor() {
		this.mtproto = new MTProto({
			api_id: config.api_id,
			api_hash: config.api_hash,
			storageOptions: {
				path: path.resolve(__dirname, `.data/${config.id}.json`),
			},
		});
	}
	async call(method, params, options = {}) {
		try {
			const result = await this.mtproto.call(method, params, options);
			return result;
		} catch (error) {
			console.log(config.id, `${method} error:`, error);
			const { error_code, error_message } = error;
			if (error_code === 420) {
				let seconds = Number(error_message.split('FLOOD_WAIT_')[1]);
				if (!seconds) seconds = Number(error_message.split('SLOWMODE_WAIT_')[1]);
				let ms = seconds * 1000;
				await sleep(ms);
				return this.call(method, params, options);
			}
			if (error_code === 303) {
				const [type, dcIdAsString] = error_message.split('_MIGRATE_');
				const dcId = Number(dcIdAsString);
				if (type === 'PHONE') {
					await this.mtproto.setDefaultDc(dcId);
				} else {
					Object.assign(options, { dcId });
				}
				return this.call(method, params, options);
			}
			return Promise.reject(error);
		}
	}
}

const api = new API();

async function getUser() {
  try {
    const user = await api.call('users.getFullUser', {
      id: {
        _: 'inputUserSelf',
      },
    });

    return user;
  } catch (error) {
    return null;
  }
}

let user;

(async () => {
  user = await getUser();
})();

Console logs:

Not found predicate with id: 168464312
Not found predicate with id: 3050349264
Not found predicate with id: 539933648
Not found predicate with id: 960050987
Not found predicate with id: 892481584
Not found predicate with id: 808663088
Not found predicate with id: 3491769632
Not found predicate with id: 3501772957
Not found predicate with id: 3502166202
Not found predicate with id: 3501248699
Not found predicate with id: 185
Not found predicate with id: 76318
Not found predicate with id: 1
Not found predicate with id: 1692164395
Not found predicate with id: 0
Not found predicate with id: 3747555843
Not found predicate with id: 1478877011
Not found predicate with id: 1639088239
Not found predicate with id: 2996303866
Not found predicate with id: 1522926040
Not found predicate with id: 2731421657
/rbd/pnpm-volume/cc9e2355-b003-40bc-8b59-bd5205d9b1ef/node_modules/@mtproto/core/src/tl/deserializer/index.js:25

const value = this.dataView.getInt32(this.offset, true);

                            ^

RangeError: Offset is outside the bounds of the DataView

at DataView.getInt32 (<anonymous>)

at Deserializer.int32 (/rbd/pnpm-volume/cc9e2355-b003-40bc-8b59-bd5205d9b1ef/node_modules/@mtproto/core/src/tl/deserializer/index.js:25:33)

at Deserializer.predicate (/rbd/pnpm-volume/cc9e2355-b003-40bc-8b59-bd5205d9b1ef/node_modules/@mtproto/core/src/tl/deserializer/index.js:112:21)

at Deserializer.vector (/rbd/pnpm-volume/cc9e2355-b003-40bc-8b59-bd5205d9b1ef/node_modules/@mtproto/core/src/tl/deserializer/index.js:89:22)

at Deserializer.module.exports (/rbd/pnpm-volume/cc9e2355-b003-40bc-8b59-bd5205d9b1ef/node_modules/@mtproto/core/src/tl/parser/index.js:1203:21)

at Deserializer.predicate (/rbd/pnpm-volume/cc9e2355-b003-40bc-8b59-bd5205d9b1ef/node_modules/@mtproto/core/src/tl/deserializer/index.js:121:15)

at RPC.handleEncryptedMessage (/rbd/pnpm-volume/cc9e2355-b003-40bc-8b59-bd5205d9b1ef/node_modules/@mtproto/core/src/rpc/index.js:449:38)

at processTicksAndRejections (node:internal/process/task_queues:96:5)

https://t.me/mtproto_core/23

hi! i have the same issue. Any way to solve it? i don't know how to solve it but it happens many times in my case...

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

6 participants