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

sanitization error if no session name is specified #2194

Closed
gekkedev opened this issue Jun 8, 2024 · 1 comment · May be fixed by JEduardo-Monti/bot-whatsapp#2 or JEduardo-Monti/bot-whatsapp#4
Closed
Labels
bug Something isn't working needs triage

Comments

@gekkedev
Copy link
Contributor

gekkedev commented Jun 8, 2024

Description

Specifying no session name during client creation causes a crash although the documentation suggests it is optional, especially in the minimal 4 line + 1 import example: https://wppconnect.io/docs/tutorial/basics/creating-client

Environment

  • WPPConnect version(s): 1.30.3
  • WA-JS version(s): 3.3.0
  • Browser: chrome-launcher@^0.15.2 / chromium-bidi@0.5.19
  • OS: Windows 11
  • Node version: v18.17.1
  • WhatsApp version: 2.2411.x
  • MultiDevice (BETA): no?

Steps to Reproduce

  1. Use the example code but do not specify a session name
  2. Observe being unable to start it

Log Output

  _       ______  ____  ______                            __
  | |     / / __ \/ __ \/ ____/___  ____  ____  ___  _____/ /_
  | | /| / / /_/ / /_/ / /   / __ \/ __ \/ __ \/ _ \/ ___/ __/
  | |/ |/ / ____/ ____/ /___/ /_/ / / / / / / /  __/ /__/ /_
  |__/|__/_/   /_/    \____/\____/_/ /_/_/ /_/\___/\___/\__/
info:     Checking for updates
info:     You're up to date
Error: Input must be string
    at sanitize (C:\wppconnect\node_modules\sanitize-filename\index.js:41:11)
    at module.exports (C:\wppconnect\node_modules\sanitize-filename\index.js:54:16)
    at Object.<anonymous> (C:\wppconnect\node_modules\@wppconnect-team\wppconnect\dist\controllers\initializer.js:173:171)
    at step (C:\wppconnect\node_modules\@wppconnect-team\wppconnect\dist\controllers\initializer.js:83:23)
    at Object.next (C:\wppconnect\node_modules\@wppconnect-team\wppconnect\dist\controllers\initializer.js:64:53)
    at fulfilled (C:\wppconnect\node_modules\@wppconnect-team\wppconnect\dist\controllers\initializer.js:55:58)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

Your Code

// Supports ES6
// import { create, Whatsapp } from '@wppconnect-team/wppconnect';
const wppconnect = require('@wppconnect-team/wppconnect');

wppconnect
  .create({
    session: 'sessionName', //Pass the name of the client you want to start the bot
    catchQR: (base64Qrimg, asciiQR, attempts, urlCode) => {
      console.log('Number of attempts to read the qrcode: ', attempts);
      console.log('Terminal qrcode: ', asciiQR);
      console.log('base64 image string qrcode: ', base64Qrimg);
      console.log('urlCode (data-ref): ', urlCode);
    },
    statusFind: (statusSession, session) => {
      console.log('Status Session: ', statusSession);
      console.log('Session name: ', session);
    },
    statusFind: (statusSession, session) => {
      console.log('Status Session: ', statusSession);
      console.log('Session name: ', session);
    }
  })
  .then((client) => start(client))
  .catch((error) => console.log(error));

Adding this to the client creation config resolves it:

    session: 'sessionName', //Pass the name of the client you want to start the bot
@gekkedev gekkedev added bug Something isn't working needs triage labels Jun 8, 2024
@gekkedev
Copy link
Contributor Author

I can confirm this works now 👍 quebom

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs triage
Projects
None yet
1 participant