Androz2091 / insta.js

💬 Object-oriented library for sending and receiving messages via Instagram
138 stars 42 forks source link

`TypeError: Cannot read property 'user' of undefined at new Message` #45

Closed dcts closed 3 years ago

dcts commented 3 years ago

how to reproduce bug

you need 3 accounts to test this:

post a story with account 3. Log in to account 2 and share that private story with the bot account by DM. Try to run Client.login(). This will throw the error:

(node:22369) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'user' of undefined
    at new Message (/home/dcts/code/insta.js/src/structures/Message.js:80:83)
    at /home/dcts/code/insta.js/src/structures/Chat.js:76:49
    at Array.forEach (<anonymous>)
    at Chat._patch (/home/dcts/code/insta.js/src/structures/Chat.js:75:24)
    at new Chat (/home/dcts/code/insta.js/src/structures/Chat.js:53:14)
    at /home/dcts/code/insta.js/src/structures/Client.js:374:26
    at Array.forEach (<anonymous>)
    at Client.login (/home/dcts/code/insta.js/src/structures/Client.js:373:17)

This error is caused because the case of a hidden story share is not catched. I added a pull request that fixes this issue by catching unavailible stories before initializing the message object.

Androz2091 commented 3 years ago

Closed by #46