question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TypeError: Cannot read properties of undefined (reading 'session')

See original GitHub issue

Olá, estou com um problema na leitura da sessão. Não está gerando o QR CODE… Alguém consegue me ajudar?

import { start } from "repl"
import {create, Whatsapp, Message, SocketState } from "venom-bot"

class Sender {
    private client: Whatsapp
    
    constructor()
    {   
        //NAO FOI FEITO NO CONSTRUTOR PRA FICAR MAIS LIMPO E EXPLICITO.
        // METODOS DE INICIALIZAÇÃO
        this.initialize()
    }

    async sendText(to: string, body:string)
    {
        //55dddnumero@c.us
        this.client.sendText(to,body)
    }

    // METODO DE FORA
    private initialize()
        {
            const qr = (base64Qrimg: string) => {}

            const status = (statusSession: string) =>
            {
                // isLogged || notLogged || browserClosed || qrReadSuccess || noOpenBrowser || deleteToken
            }

            const start = (client: Whatsapp) =>
            {
                this.client = client

                this.sendText("5521982314899@c.us", "Ola, tudo bem? esse é um teste")
            }

            create('arcane-sender', qr, status)
            .then((client)=> start(client))
            .catch((error) => console.error(error))
        }
}
export default Sender

O ERRO:

TypeError: Cannot read properties of undefined (reading 'session') at C:\Users\Antonio Oliveira\Desktop\JavaScript\node_modules\venom-bot\src\controllers\initializer.ts:177:48 at step (C:\Users\Antonio Oliveira\Desktop\JavaScript\node_modules\venom-bot\dist\controllers\initializer.js:98:23) at Object.next (C:\Users\Antonio Oliveira\Desktop\JavaScript\node_modules\venom-bot\dist\controllers\initializer.js:79:53) at C:\Users\Antonio Oliveira\Desktop\JavaScript\node_modules\venom-bot\dist\controllers\initializer.js:73:71 at new Promise (<anonymous>) at __awaiter (C:\Users\Antonio Oliveira\Desktop\JavaScript\node_modules\venom-bot\dist\controllers\initializer.js:69:12) at create (C:\Users\Antonio Oliveira\Desktop\JavaScript\node_modules\venom-bot\dist\controllers\initializer.js:117:12) at Sender.initialize (C:\Users\Antonio Oliveira\Desktop\JavaScript\src\sender.ts:37:19) at new Sender (C:\Users\Antonio Oliveira\Desktop\JavaScript\src\sender.ts:11:14) at Object.<anonymous> (C:\Users\Antonio Oliveira\Desktop\JavaScript\src\app.ts:4:16)

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:22 (1 by maintainers)

github_iconTop GitHub Comments

5reactions
lorangel37commented, May 18, 2022

Realmente se trata de algo da versão 4.0.11, pra resolver é só colocar a versão 4.0.10 conforme o @pedrolucasD disse. npm i --save venom-bot@4.0.10

2reactions
Feeh03114commented, Oct 29, 2022

estou usando a versão venom-bot@4.0.10

I solved this problem from version 4.3 by doing the following step: Step 1: Access node_modules/venom-bot/controllers/initializer.js Step 2: remove this.session to session Step 3: save ready

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeError: Cannot read property 'sessions' of undefined
It seems like some time your response is getting the JSON data in the way which you are trying to access, but some...
Read more >
Cannot read properties of undefined (reading 'session') · Issue ...
TypeError : Cannot read properties of undefined (reading 'session') #4845 ... The session is not defined in the pageProps .
Read more >
Cannot Read Property of Undefined in JavaScript - Rollbar
TypeError: Cannot read property of undefined occurs when a property is read or a function is called on an undefined variable.
Read more >
Cannot read properties of undefined SessionInvalidated - Kofax
Cannot read properties of undefined (reading 'SessionInvalidated'). Another symptom is being stuck in a never-ending loop with this message:.
Read more >
cannot read properties of undefined (reading 'auth') - You.com
To fix the “cannot read property of undefined” error, check that the value is not undefined before accessing the property. For example, in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found