Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

276
Views
UnhandledPromiseRejectionWarning: KnexTimeoutError: Knex: Timeout adquiriendo una conexión

Estoy tratando de conectar la base de datos a mi bot de Telegram y quiero usar knex para ello. Yo uso MySQL. Se crean la base de datos y la tabla. También puedo verlo en la página /phpMyAdmin, por lo que funciona (he usado las mismas credenciales, que se usan en mi código). He verificado dos veces los datos de configuración, es correcto. Aquí está el código de creación del cliente:

 this.knex = knex({ client: "mysql", connection: { host: this.config.HOST, port: this.config.PORT, user: this.config.USERNAME, password: this.config.PASSWORD, database: this.config.DATABASE, }, //I've added next line, cuz I was thinking there is pool error, but it didn't work pool: { min: 0, max: 7 }, });

Lo tengo dentro de mi clase. Aquí está el método, estoy tratando de llamar (Ninguno de console.logs funciona):

 async getManagers() { const managers = await this.knex .select("*") .from("users") .where("isManager", 1) .then((data) => { console.log(data); }); console.log(managers); }

Estoy absolutamente seguro de que tengo una tabla llamada user y el campo isManager en ella. Así es como lo llamo:

 const dbDataService = new DBDataService(databaseConfiguration); dbDataService.getManagers();

Sigo recibiendo esto:

 (node:31227) UnhandledPromiseRejectionWarning: KnexTimeoutError: Knex: Timeout acquiring a connection. The pool is probably full. Are you missing a .transacting(trx) call? at Client_MySQL.acquireConnection (/project/node_modules/knex/lib/client.js:348:26) (node:31227) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 4)

Si ayuda, agregaré mi lista de dependencias:

 "dependencies": { "dotenv": "^11.0.0", "mysql": "^2.1.0", "knex": "^0.21.1", "log4js": "^6.3.0", "node-telegram-bot-api": "^0.56.0" }

Intenté usar diferentes versiones de knex (1.0.1) y sigo recibiendo este error. Ya he pasado todo el día para hacer que esto funcione, pero todavía no puedo resolverlo. Espero que alguien de ustedes me ayude. Gracias.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

En realidad, me equivoqué con PORT. Debería estar usando 3306, pero no 80.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!