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.

Cannot read property 'slice' of undefined

See original GitHub issue
const mysql = require("mysql2/promise");

var mpool = mysql.createPool({
  connectionLimit: 10,
  host: process.env.MYSQL_IP,
  user: process.env.MYSQL_USER,
  password: process.env.MYSQL_PASSWORD,
  database: process.env.MYSQL_DB,
});

async function getSomething() {
    const [rows, fields] = await mpool.execute(
        `select query`
      );
    console.log(rows);
}

query never runs and outputs this error below. isql is working with same login settings:

node_modules/mysql2/lib/auth_41.js:78 const authPluginData2 = scramble2.slice(0, 12);

                                ^

TypeError: Cannot read property ‘slice’ of undefined at Object.exports.calculateTokenFromPasswordSha (node_modules/mysql2/lib/auth_41.js:78:37) at Object.token [as calculateToken] (node_modules/mysql2/lib/auth_41.js:68:18) at new HandshakeResponse (node_modules/mysql2/lib/packets/handshake_response.js:28:26) at ClientHandshake.sendCredentials (node_modules/mysql2/lib/commands/client_handshake.js:52:31) at ClientHandshake.handshakeInit (node_modules/mysql2/lib/commands/client_handshake.js:137:12) at ClientHandshake.execute (node_modules/mysql2/lib/commands/command.js:39:22) at PoolConnection.handlePacket (/node_modules/mysql2/lib/connection.js:425:32) at PacketParser.onPacket (node_modules/mysql2/lib/connection.js:75:12) at PacketParser.executeStart (node_modules/mysql2/lib/packet_parser.js:75:16) at Socket.<anonymous> (node_modules/mysql2/lib/connection.js:82:25)

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:9 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
testncommented, Nov 10, 2021

For something that was released 17 years ago, I would say not a lot 😂

0reactions
sidorarescommented, Nov 10, 2021

we don’t have to support every old server version, but I think good behaving driver should not 1) crash when server version is not supported 2) return good error explaining what happened and how to fix

re particular version ( 4.1 and older ) - not sure how many people use it. I’d say not enough to justify dev effort but don’t have evidence to support. There is always drop in mysqljs/mysql replacement for those who must use old server

Read more comments on GitHub >

github_iconTop Results From Across the Web

Problem with error Cannot read property 'slice' of undefined
I faced the same error today, and solved it by initializing the array to an empty array before performing any slice ...
Read more >
TypeError: Cannot read Property 'slice' of Undefined in JS
The "Cannot read property 'slice' of undefined" error occurs when the slice() method is called on an undefined value. To solve the error,...
Read more >
TypeError: Cannot read property 'slice' of undefined - Support
Hello, I encountered the same problem with the new version solc compiler. ... Error: TypeError: Cannot read property 'slice' of undefined at ...
Read more >
Cannot read property 'slice' of undefined error when trying to ...
As the title says, I am getting a Cannot read property 'slice' of undefined error in the console when trying to embed a...
Read more >
TypeError: Cannot read property 'slice' of undefined - MongoDB
So you can not retrieve that token because there is no Header so there is undefined variable. You are trying to slice that...
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