Open AlexOwl opened 7 months ago
ой ватафак а почему оно вообще билдилось тогда...
панятна
get message.forwardOrigin will throw error
я forwardOrigin нигде не использую
не очень понял а как ты ошибку то затриггерил? есть minimal reproducible code?
я выкатил как отдельный коммит но пока что без новой версии, надо понять как ты затриггерил это
Мне в чат прилетело это (бот в чате юзается). Туда прислали сообщ с другого канала, в стэке ошибки есть memoizeGetters где вызвался геттер forwardOrigin и от этого крашилось. Где именно memoizeGetters вызывался не смог посмотреть, вероятно в каком-то лупе.
@AlexOwl фулл трейсбек не сможешь достать, да?
По нему непонятно
unexpected uncaugh error #7899 Error: TypeError: Cannot read properties of undefined (reading 'type')
at Message.get forwardOrigin (/app/node_modules/puregram/lib/common/structures/message.js:102:33)
at Message.get [as forwardOrigin] (/app/node_modules/puregram/lib/utils/helpers.js:151:33)
at serialize (/app/node_modules/inspectable/lib/index.js:36:37)
at Message.value (/app/node_modules/inspectable/lib/index.js:18:29)
at formatValue (node:internal/util/inspect:805:19)
at formatProperty (node:internal/util/inspect:1926:11)
at formatRaw (node:internal/util/inspect:1054:9)
at formatValue (node:internal/util/inspect:840:10)
at Object.inspect (node:internal/util/inspect:364:10)
at Object.inspect (/app/node_modules/inspectable/lib/index.js:12:34)
This is caused by either a bug in Node.js or incorrect usage of Node.js internals.
Please open an issue with this stack trace at https://github.com/nodejs/node/issues
at new NodeError (node:internal/errors:405:5)
at Function.fail (node:internal/assert:20:9)
at handleMaxCallStackSize (node:internal/util/inspect:1556:10)
at formatRaw (node:internal/util/inspect:1062:12)
at formatValue (node:internal/util/inspect:840:10)
at Object.inspect (node:internal/util/inspect:364:10)
at Object.inspect (/app/node_modules/inspectable/lib/index.js:12:34)
at stringify (/app/node_modules/inspectable/lib/index.js:5:153)
at MessageContext.value (/app/node_modules/inspectable/lib/index.js:19:20)
at formatValue (node:internal/util/inspect:805:19) {
code: 'ERR_INTERNAL_ASSERTION'
}
Error: TypeError: Cannot read properties of undefined (reading 'type')
at Message.get forwardOrigin (/app/node_modules/puregram/lib/common/structures/message.js:102:33)
at Message.get [as forwardOrigin] (/app/node_modules/puregram/lib/utils/helpers.js:151:33)
at serialize (/app/node_modules/inspectable/lib/index.js:36:37)
at Message.value (/app/node_modules/inspectable/lib/index.js:18:29)
at formatValue (node:internal/util/inspect:805:19)
at formatProperty (node:internal/util/inspect:1926:11)
at formatRaw (node:internal/util/inspect:1054:9)
at formatValue (node:internal/util/inspect:840:10)
at Object.inspect (node:internal/util/inspect:364:10)
at Object.inspect (/app/node_modules/inspectable/lib/index.js:12:34)
This is caused by either a bug in Node.js or incorrect usage of Node.js internals.
Please open an issue with this stack trace at https://github.com/nodejs/node/issues
at new NodeError (node:internal/errors:405:5)
at Function.fail (node:internal/assert:20:9)
at handleMaxCallStackSize (node:internal/util/inspect:1556:10)
at formatRaw (node:internal/util/inspect:1062:12)
at formatValue (node:internal/util/inspect:840:10)
at Object.inspect (node:internal/util/inspect:364:10)
at Object.inspect (/app/node_modules/inspectable/lib/index.js:12:34)
at stringify (/app/node_modules/inspectable/lib/index.js:5:153)
at MessageContext.value (/app/node_modules/inspectable/lib/index.js:19:20)
at formatValue (node:internal/util/inspect:805:19)
> NX Successfully ran target serve for project
продолжение
После вот этого упало
puregram:updates:handleUpdate update payload: {"message_id":***,"from":{"id":***,"is_bot":false,"first_name":"***","username":"***"},"chat":{"id":***,"title":"***","type":"supergroup"},"date":***,"message_thread_id":***,"reply_to_message":{"message_id":**,"from":{"id":***,"is_bot":false,"first_name":"***","last_name":"***","username":"***","is_premium":true},"chat":{"id":***,"title":"***","type":"supergroup"},"date":***,"forward_origin":{"type":"channel","chat":{"id":***,"title":"***","username":"***","type":"channel"},"message_id":***,"date":***},"forward_from_chat":{"id":***,"title":"***","username":"***","type":"channel"},"forward_from_message_id":***,"forward_date":***,"photo":[{"file_id":"***","file_unique_id":"***","file_size":***,"width":67,"height":90},{"file_id":"***","file_unique_id":"***","file_size":***,"width":240,"height":320},{"file_id":"***","file_unique_id":"***","file_size":***,"width":600,"height":800},{"file_id":"***","file_unique_id":"***","file_size":***,"width":960,"height":1280}],"caption":"***","caption_entities"](***;:[{"offset":27,"length":32,"type":"url"}]},"text":"***"}
good с утра погляжу
надеюсь что тот possible fix на самом деле fix, не очень понимаю как мне потестить прям нормально
привет! проблема с тех пор не возникала?
the bug
https://github.com/nitreojs/puregram/blob/b431d9303de1696999e7f41f45d7c4d7d264c272/packages/puregram/src/common/structures/message.ts#L126
steps to reproduce
steps to reproduce the behavior: get message.forwardOrigin will throw error TypeError: Cannot read properties of undefined (reading 'type')
expected behavior
use this.payload.forward_origin.type
environment
puregram
2.25.1
node
latest
TypeScript
latest
yarn
ornpm
latest
additional context
Вместо this.payload.origin вероятно надо использовать forward_origin (this.payload.forward_origin) https://core.telegram.org/bots/api#message
От пересланного сообщения из другого чата крашится фулл приложение, потому что memoizeGetters в каком-то месте пытается взять forwardOrigin, который в свою очередь сыпет ошибку
Возможно в memoizeGetters стоит еще повесить try catch, чтобы просто так приложение не падало, если этот функционал не используется (я forwardOrigin нигде не использую, но просто от прилета сообщения ошибка ловится уже на process.on("uncaughtException", ...), даже не в telegram.onError(...) )