sidorares / node-mysql2

:zap: fast mysqljs/mysql compatible mysql driver for node.js
https://sidorares.github.io/node-mysql2/
MIT License
4.07k stars 618 forks source link

What's the problem with starting an error? #936

Closed 13349253469 closed 4 years ago

13349253469 commented 5 years ago

[egg-scripts] Got error when startup: [egg-scripts] Trace [egg-scripts] at Packet.readLengthCodedNumberExt (/app/project/egg-catalogbuy/node_modules/mysql2/lib/packets/packet.js:226:13) [egg-scripts] at Packet.readLengthCodedNumber (/app/project/egg-catalogbuy/node_modules/mysql2/lib/packets/packet.js:188:17) [egg-scripts] at Packet.readLengthCodedString (/app/project/egg-catalogbuy/node_modules/mysql2/lib/packets/packet.js:355:22) [egg-scripts] at new ResultSetHeader (/app/project/egg-catalogbuy/node_modules/mysql2/lib/packets/resultset_header.js:71:52) [egg-scripts] at Query.resultsetHeader (/app/project/egg-catalogbuy/node_modules/mysql2/lib/commands/query.js:104:16) [egg-scripts] at Query.execute (/app/project/egg-catalogbuy/node_modules/mysql2/lib/commands/command.js:39:22) [egg-scripts] at Connection.handlePacket (/app/project/egg-catalogbuy/node_modules/mysql2/lib/connection.js:449:32) [egg-scripts] at PacketParser.Connection.packetParser.p [as onPacket] (/app/project/egg-catalogbuy/node_modules/mysql2/lib/connection.js:72:12) [egg-scripts] at PacketParser.executeStart (/app/project/egg-catalogbuy/node_modules/mysql2/lib/packet_parser.js:75:16) [egg-scripts] at Socket.Connection.stream.on.data (/app/project/egg-catalogbuy/node_modules/mysql2/lib/connection.js:79:25) [egg-scripts] at emitOne (events.js:116:13) [egg-scripts] at Socket.emit (events.js:211:7) [egg-scripts] at addChunk (_stream_readable.js:263:12) [egg-scripts] at readableAddChunk (_stream_readable.js:250:11) [egg-scripts] at Socket.Readable.push (_stream_readable.js:208:10) [egg-scripts] at TCP.onread (net.js:594:20) [egg-scripts] 2019-03-19 23:38:45,527 ERROR 23733 nodejs.unhandledExceptionError: Should not reach here: undefined [egg-scripts] at Packet.readLengthCodedNumberExt (/app/project/egg-catalogbuy/node_modules/mysql2/lib/packets/packet.js:227:11) [egg-scripts] at Packet.readLengthCodedNumber (/app/project/egg-catalogbuy/node_modules/mysql2/lib/packets/packet.js:188:17) [egg-scripts] at Packet.readLengthCodedString (/app/project/egg-catalogbuy/node_modules/mysql2/lib/packets/packet.js:355:22) [egg-scripts] at new ResultSetHeader (/app/project/egg-catalogbuy/node_modules/mysql2/lib/packets/resultset_header.js:71:52) [egg-scripts] at Query.resultsetHeader (/app/project/egg-catalogbuy/node_modules/mysql2/lib/commands/query.js:104:16) [egg-scripts] at Query.execute (/app/project/egg-catalogbuy/node_modules/mysql2/lib/commands/command.js:39:22) [egg-scripts] at Connection.handlePacket (/app/project/egg-catalogbuy/node_modules/mysql2/lib/connection.js:449:32) [egg-scripts] at PacketParser.Connection.packetParser.p [as onPacket] (/app/project/egg-catalogbuy/node_modules/mysql2/lib/connection.js:72:12) [egg-scripts] at PacketParser.executeStart (/app/project/egg-catalogbuy/node_modules/mysql2/lib/packet_parser.js:75:16) [egg-scripts] at Socket.Connection.stream.on.data (/app/project/egg-catalogbuy/node_modules/mysql2/lib/connection.js:79:25) [egg-scripts] at emitOne (events.js:116:13) [egg-scripts] at Socket.emit (events.js:211:7) [egg-scripts] at addChunk (_stream_readable.js:263:12) [egg-scripts] at readableAddChunk (_stream_readable.js:250:11) [egg-scripts] at Socket.Readable.push (_stream_readable.js:208:10) [egg-scripts] at TCP.onread (net.js:594:20) [egg-scripts] name: "unhandledExceptionError" [egg-scripts] pid: 23733 [egg-scripts] hostname: lhqcdz-uaes-ecom-nodejs0-ebaeef1e.novalocal [egg-scripts]

13349253469 commented 5 years ago

This problem occurs on a private cloud deployment.

13349253469 commented 5 years ago

Public cloud deployment is not the problem

sidorares commented 5 years ago

Sorry, but I need more information to help, ideally a self-contained example that shows same error

13349253469 commented 5 years ago

Currently only these error messages

13349253469 commented 5 years ago

my English is not good

13349253469 commented 5 years ago

Sorry, but I need more information to help, ideally a self-contained example that shows same error

byte1 0 byte1 0 byte1 0 len 0 byte1 22 byte1 17 byte1 9 len 9 byte1 6 len 6 byte1 1 byte1 49 len 49 byte1 undefined Trace at Packet.readLengthCodedNumberExt (/app/project/egg-catalogbuy/node_modules/mysql2/lib/packets/packet.js:227:13) at Packet.readLengthCodedNumber (/app/project/egg-catalogbuy/node_modules/mysql2/lib/packets/packet.js:189:17) at Packet.readLengthCodedString (/app/project/egg-catalogbuy/node_modules/mysql2/lib/packets/packet.js:356:22) at new ResultSetHeader (/app/project/egg-catalogbuy/node_modules/mysql2/lib/packets/resultset_header.js:71:52) at Query.resultsetHeader (/app/project/egg-catalogbuy/node_modules/mysql2/lib/commands/query.js:104:16) at Query.execute (/app/project/egg-catalogbuy/node_modules/mysql2/lib/commands/command.js:39:22) at Connection.handlePacket (/app/project/egg-catalogbuy/node_modules/mysql2/lib/connection.js:449:32) at PacketParser.Connection.packetParser.p [as onPacket] (/app/project/egg-catalogbuy/node_modules/mysql2/lib/connection.js:72:12) at PacketParser.executeStart (/app/project/egg-catalogbuy/node_modules/mysql2/lib/packet_parser.js:75:16) at Socket.Connection.stream.on.data (/app/project/egg-catalogbuy/node_modules/mysql2/lib/connection.js:79:25) at emitOne (events.js:116:13) at Socket.emit (events.js:211:7) at addChunk (_stream_readable.js:263:12) at readableAddChunk (_stream_readable.js:250:11) at Socket.Readable.push (_stream_readable.js:208:10) at TCP.onread (net.js:594:20)

image

-- readLengthCodedNumber(bigNumberStrings, signed) { const byte1 = this.buffer[this.offset++]; console.log("byte1",byte1) if (byte1 < 251) { return byte1; } return this.readLengthCodedNumberExt(byte1, bigNumberStrings, signed); }

readLengthCodedString(encoding) { const len = this.readLengthCodedNumber(); console.log('len',len) // TODO: check manually first byte here to avoid polymorphic return type? if (len === null) { return null; } this.offset += len; // TODO: Use characterSetCode to get proper encoding // https://github.com/sidorares/node-mysql2/pull/374 return StringParser.decode( this.buffer.slice(this.offset - len, this.offset), encoding ); }

13349253469 commented 5 years ago

Sorry, but I need more information to help, ideally a self-contained example that shows same error

Why is there undefined here?

sidorares commented 5 years ago

The only thing I can think of is that index is out of buffer boundary. Can you change your console.log to be console.log("byte1",byte1, this.buffer.length, offset) ?

13349253469 commented 5 years ago

The only thing I can think of is that index is out of buffer boundary. Can you change your console.log to be console.log("byte1",byte1, this.buffer.length, offset) ?

offset 5 buffer 35 byte1 0 offset 6 buffer 35 byte1 0 offset 11 buffer 35 byte1 0 len 0 offset 12 buffer 35 byte1 22 offset 14 buffer 35 byte1 17 offset 15 buffer 35 byte1 9 len 9 offset 25 buffer 35 byte1 6 len 6 offset 33 buffer 35 byte1 1 offset 34 buffer 35 byte1 49 len 49 offset 84 buffer 35 byte1 undefined Trace at Packet.readLengthCodedNumberExt (/app/project/egg-catalogbuy/node_modules/mysql2/lib/packets/packet.js:229:13) at Packet.readLengthCodedNumber (/app/project/egg-catalogbuy/node_modules/mysql2/lib/packets/packet.js:191:17) at Packet.readLengthCodedString (/app/project/egg-catalogbuy/node_modules/mysql2/lib/packets/packet.js:358:22) at new ResultSetHeader (/app/project/egg-catalogbuy/node_modules/mysql2/lib/packets/resultset_header.js:71:52) at Query.resultsetHeader (/app/project/egg-catalogbuy/node_modules/mysql2/lib/commands/query.js:104:16) at Query.execute (/app/project/egg-catalogbuy/node_modules/mysql2/lib/commands/command.js:39:22) at Connection.handlePacket (/app/project/egg-catalogbuy/node_modules/mysql2/lib/connection.js:449:32) at PacketParser.Connection.packetParser.p [as onPacket] (/app/project/egg-catalogbuy/node_modules/mysql2/lib/connection.js:72:12) at PacketParser.executeStart (/app/project/egg-catalogbuy/node_modules/mysql2/lib/packet_parser.js:75:16) at Socket.Connection.stream.on.data (/app/project/egg-catalogbuy/node_modules/mysql2/lib/connection.js:79:25) at emitOne (events.js:116:13) at Socket.emit (events.js:211:7) at addChunk (_stream_readable.js:263:12) at readableAddChunk (_stream_readable.js:250:11) at Socket.Readable.push (_stream_readable.js:208:10) at TCP.onread (net.js:594:20) image

13349253469 commented 5 years ago

The only thing I can think of is that index is out of buffer boundary. Can you change your console.log to be console.log("byte1",byte1, this.buffer.length, offset) ?

What is the cause of this situation?

13349253469 commented 5 years ago

The only thing I can think of is that index is out of buffer boundary. Can you change your console.log to be console.log("byte1",byte1, this.buffer.length, offset) ?

I am more anxious now, I don’t know where to solve it.

sidorares commented 5 years ago

Can you add packet.dump() before this line - https://github.com/sidorares/node-mysql2/blob/78aeaab5d7daa3786f40102d443cedccca148f88/lib/commands/query.js#L104

So that I can copy packet data and reconstruct what happens on your side

13349253469 commented 5 years ago

Can you add packet.dump() before this line -

node-mysql2/lib/commands/query.js

Line 104 in 78aeaab

const rs = new Packets.ResultSetHeader(packet, connection); So that I can copy packet data and reconstruct what happens on your side

ok!

13349253469 commented 5 years ago

Can you add packet.dump() before this line -

node-mysql2/lib/commands/query.js

Line 104 in 78aeaab

const rs = new Packets.ResultSetHeader(packet, connection); So that I can copy packet data and reconstruct what happens on your side

[ '\u001f\u0000\u0000\u0001\u0000\u0000\u0000\u0002@\u0000\u0000\u0000\u0016\u0000\u0011\ttime_zone\u0006+00:00\u0002\u00011' ] <Buffer 1f 00 00 01 00 00 00 02 40 00 00 00 16 00 11 09 74 69 6d 65 5f 7a 6f 6e 65 06 2b 30 30 3a 30 30 02 01 31> 35 1 len 0 len 9 len 6 len 49 Trace at Packet.readLengthCodedNumberExt (/app/project/egg-catalogbuy/node_modules/mysql2/lib/packets/packet.js:229:13) at Packet.readLengthCodedNumber (/app/project/egg-catalogbuy/node_modules/mysql2/lib/packets/packet.js:191:17) at Packet.readLengthCodedString (/app/project/egg-catalogbuy/node_modules/mysql2/lib/packets/packet.js:358:22) at new ResultSetHeader (/app/project/egg-catalogbuy/node_modules/mysql2/lib/packets/resultset_header.js:71:52) at Query.resultsetHeader (/app/project/egg-catalogbuy/node_modules/mysql2/lib/commands/query.js:105:16) at Query.execute (/app/project/egg-catalogbuy/node_modules/mysql2/lib/commands/command.js:39:22) at Connection.handlePacket (/app/project/egg-catalogbuy/node_modules/mysql2/lib/connection.js:449:32) at PacketParser.Connection.packetParser.p [as onPacket] (/app/project/egg-catalogbuy/node_modules/mysql2/lib/connection.js:72:12) at PacketParser.executeStart (/app/project/egg-catalogbuy/node_modules/mysql2/lib/packet_parser.js:75:16) at Socket.Connection.stream.on.data (/app/project/egg-catalogbuy/node_modules/mysql2/lib/connection.js:79:25) at emitOne (events.js:116:13) at Socket.emit (events.js:211:7) at addChunk (_stream_readable.js:263:12) at readableAddChunk (_stream_readable.js:250:11) at Socket.Readable.push (_stream_readable.js:208:10) at TCP.onread (net.js:594:20)

sidorares commented 5 years ago

Thanks, I'll have a look

sidorares commented 5 years ago

What's your server version @13349253469 ? packet layout does not look matching docs ( or there is a mistake in docs )

Also can you post your client & server connection flags? If you connect with 'debug' option enabled you'll see them at the meginning

13349253469 commented 5 years ago

What's your server version @13349253469 ? packet layout does not look matching docs ( or there is a mistake in docs )

Also can you post your client & server connection flags? If you connect with 'debug' option enabled you'll see them at the meginning

mysql server version is 5.7.19

13349253469 commented 5 years ago

Also can you post your client & server connection flags? If you connect with 'debug' option enabled you'll see them at the meginning

Also can you post your client & server connection flags? If you connect with 'debug' option enabled you'll see them at the meginning --Can you understand this operation more clearly?

13349253469 commented 5 years ago

What's your server version @13349253469 ? packet layout does not look matching docs ( or there is a mistake in docs )

Also can you post your client & server connection flags? If you connect with 'debug' option enabled you'll see them at the meginning

image

sidorares commented 5 years ago

No, different debug - see https://github.com/mysqljs/mysql#debugging-and-reporting-problems when you create connection, pass debug: true flag similar to mysql.createConnection({debug: true})

13349253469 commented 5 years ago

Thanks, I'll have a look

No, different debug - see https://github.com/mysqljs/mysql#debugging-and-reporting-problems when you create connection, pass debug: true flag similar to mysql.createConnection({debug: true})

I am using sequelize this module, I did not find the method of setting

sidorares commented 5 years ago

So the problem I see is when code reaches this line at https://github.com/sidorares/node-mysql2/blob/78aeaab5d7daa3786f40102d443cedccca148f88/lib/packets/resultset_header.js#L71

content of the packet is "0x01 0x31" while according to the specs ( see the part for SESSION_TRACK_STATE_CHANGE ) it should be "0x02 0x01 0x31". I'll need to figure out if it's spec error or bug in the client or server

@ruiquelhas maybe you can clarify? Looks like an error in docs to me.

13349253469 commented 5 years ago

No, different debug - see https://github.com/mysqljs/mysql#debugging-and-reporting-problems when you create connection, pass debug: true flag similar to mysql.createConnection({debug: true})

-[appuser@lhqcdz-uaes-ecom-nodejs0-ebaeef1e egg-catalogbuy]$ npm run dev

egg-catalogbuy@1.0.0 dev /app/project/egg-catalogbuy egg-bin dev

[egg-ts-helper] create /app/project/egg-catalogbuy/typings/app/controller/index.d.ts [egg-ts-helper] create /app/project/egg-catalogbuy/typings/config/index.d.ts [egg-ts-helper] create /app/project/egg-catalogbuy/typings/app/service/index.d.ts [egg-ts-helper] create /app/project/egg-catalogbuy/typings/app/index.d.ts 2019-03-27 11:47:56,290 INFO 18609 [master] node version v8.9.4 2019-03-27 11:47:56,291 INFO 18609 [master] egg version 2.19.0 sequelize deprecated String based operators are now deprecated. Please use Symbol based operators for better security, read more at http://docs.sequelizejs.com/manual/tutorial/querying.html#operators node_modules/sequelize/lib/sequelize.js:242:13 Add command: ClientHandshake Add command: ClientHandshake raw: 0a352e372e392d7570726f78792d302e302e3100f32000004950457c4016650e008fe22d02008f0115000000000000000000006073527520404e6645311f7e006d7973716c5f6e61746976655f70617373776f726400 Trace at Connection.handlePacket (/app/project/egg-catalogbuy/node_modules/mysql2/lib/connection.js:419:17) at PacketParser.Connection.packetParser.p [as onPacket] (/app/project/egg-catalogbuy/node_modules/mysql2/lib/connection.js:72:12) at PacketParser.executeStart (/app/project/egg-catalogbuy/node_modules/mysql2/lib/packet_parser.js:75:16) at Socket.Connection.stream.on.data (/app/project/egg-catalogbuy/node_modules/mysql2/lib/connection.js:79:25) at emitOne (events.js:116:13) at Socket.emit (events.js:211:7) at addChunk (_stream_readable.js:263:12) at readableAddChunk (_stream_readable.js:250:11) at Socket.Readable.push (_stream_readable.js:208:10) at TCP.onread (net.js:594:20) 0 undefined ==> ClientHandshake#unknown name(0,,90) Server hello packet: capability flags:26206863=(long password, found rows, long flag, connect with db, local files, protocol 41, transactions, reserved, secure connection, multi statements, multi results, ps multi results, plugin auth, session track, deprecate eof) Sending handshake packet: flags:8582093=(long password, long flag, connect with db, odbc, local files, ignore space, protocol 41, ignore sigpipe, transactions, reserved, secure connection, multi results, session track) 0 8435 <== ClientHandshake#unknown name(1,,79) 0 8435 <== 4b000001cdf3820000000000e0000000000000000000000000000000000000000000000075616573757365720014c04464eced2de98bec98fc32ecca41605597edb6756165735f626173355f697000 raw: 0a352e372e392d7570726f78792d302e302e3100562e0000281f1808406a1378008fe22d02008f01150000000000000000000036600a421663150139150d6d006d7973716c5f6e61746976655f70617373776f726400 image

13349253469 commented 5 years ago

So the problem I see is when code reaches this line at node-mysql2/lib/packets/resultset_header.js

Line 71 in 78aeaab

stateChanges.trackStateChange = packet.readLengthCodedString( content of the packet is "0x01 0x31" while according to the specs ( see the part for SESSION_TRACK_STATE_CHANGE ) it should be "0x02 0x01 0x31". I'll need to figure out if it's spec error or bug in the client or server

@ruiquelhas maybe you can clarify? Looks like an error in docs to me.

This is all the information

egg-catalogbuy@1.0.0 dev /app/project/egg-catalogbuy egg-bin dev

[egg-ts-helper] create /app/project/egg-catalogbuy/typings/app/controller/index.d.ts [egg-ts-helper] create /app/project/egg-catalogbuy/typings/config/index.d.ts [egg-ts-helper] create /app/project/egg-catalogbuy/typings/app/service/index.d.ts [egg-ts-helper] create /app/project/egg-catalogbuy/typings/app/index.d.ts 2019-03-27 11:47:56,290 INFO 18609 [master] node version v8.9.4 2019-03-27 11:47:56,291 INFO 18609 [master] egg version 2.19.0 sequelize deprecated String based operators are now deprecated. Please use Symbol based operators for better security, read more at http://docs.sequelizejs.com/manual/tutorial/querying.html#operators node_modules/sequelize/lib/sequelize.js:242:13 Add command: ClientHandshake Add command: ClientHandshake raw: 0a352e372e392d7570726f78792d302e302e3100f32000004950457c4016650e008fe22d02008f0115000000000000000000006073527520404e6645311f7e006d7973716c5f6e61746976655f70617373776f726400 Trace at Connection.handlePacket (/app/project/egg-catalogbuy/node_modules/mysql2/lib/connection.js:419:17) at PacketParser.Connection.packetParser.p [as onPacket] (/app/project/egg-catalogbuy/node_modules/mysql2/lib/connection.js:72:12) at PacketParser.executeStart (/app/project/egg-catalogbuy/node_modules/mysql2/lib/packet_parser.js:75:16) at Socket.Connection.stream.on.data (/app/project/egg-catalogbuy/node_modules/mysql2/lib/connection.js:79:25) at emitOne (events.js:116:13) at Socket.emit (events.js:211:7) at addChunk (_stream_readable.js:263:12) at readableAddChunk (_stream_readable.js:250:11) at Socket.Readable.push (_stream_readable.js:208:10) at TCP.onread (net.js:594:20) 0 undefined ==> ClientHandshake#unknown name(0,,90) Server hello packet: capability flags:26206863=(long password, found rows, long flag, connect with db, local files, protocol 41, transactions, reserved, secure connection, multi statements, multi results, ps multi results, plugin auth, session track, deprecate eof) Sending handshake packet: flags:8582093=(long password, long flag, connect with db, odbc, local files, ignore space, protocol 41, ignore sigpipe, transactions, reserved, secure connection, multi results, session track) 0 8435 <== ClientHandshake#unknown name(1,,79) 0 8435 <== 4b000001cdf3820000000000e0000000000000000000000000000000000000000000000075616573757365720014c04464eced2de98bec98fc32ecca41605597edb6756165735f626173355f697000 raw: 0a352e372e392d7570726f78792d302e302e3100562e0000281f1808406a1378008fe22d02008f01150000000000000000000036600a421663150139150d6d006d7973716c5f6e61746976655f70617373776f726400 Trace at Connection.handlePacket (/app/project/egg-catalogbuy/node_modules/mysql2/lib/connection.js:419:17) at PacketParser.Connection.packetParser.p [as onPacket] (/app/project/egg-catalogbuy/node_modules/mysql2/lib/connection.js:72:12) at PacketParser.executeStart (/app/project/egg-catalogbuy/node_modules/mysql2/lib/packet_parser.js:75:16) at Socket.Connection.stream.on.data (/app/project/egg-catalogbuy/node_modules/mysql2/lib/connection.js:79:25) at emitOne (events.js:116:13) at Socket.emit (events.js:211:7) at addChunk (_stream_readable.js:263:12) at readableAddChunk (_stream_readable.js:250:11) at Socket.Readable.push (_stream_readable.js:208:10) at TCP.onread (net.js:594:20) 1 undefined ==> ClientHandshake#unknown name(0,,90) Server hello packet: capability flags:26206863=(long password, found rows, long flag, connect with db, local files, protocol 41, transactions, reserved, secure connection, multi statements, multi results, ps multi results, plugin auth, session track, deprecate eof) Sending handshake packet: flags:8582093=(long password, long flag, connect with db, odbc, local files, ignore space, protocol 41, ignore sigpipe, transactions, reserved, secure connection, multi results, session track) 1 11862 <== ClientHandshake#unknown name(1,,83) 1 11862 <== 4f000001cdf3820000000000e0000000000000000000000000000000000000000000000075616573757365720014578d63cc35155c9684de20b7eece9bc1d432f0b0756165735f69705f627573696e65737300 raw: 0000000200000000 Trace at Connection.handlePacket (/app/project/egg-catalogbuy/node_modules/mysql2/lib/connection.js:419:17) at PacketParser.Connection.packetParser.p [as onPacket] (/app/project/egg-catalogbuy/node_modules/mysql2/lib/connection.js:72:12) at PacketParser.executeStart (/app/project/egg-catalogbuy/node_modules/mysql2/lib/packet_parser.js:75:16) at Socket.Connection.stream.on.data (/app/project/egg-catalogbuy/node_modules/mysql2/lib/connection.js:79:25) at emitOne (events.js:116:13) at Socket.emit (events.js:211:7) at addChunk (_stream_readable.js:263:12) at readableAddChunk (_stream_readable.js:250:11) at Socket.Readable.push (_stream_readable.js:208:10) at TCP.onread (net.js:594:20) 1 11862 ==> ClientHandshake#unknown name(2,maybeOK,12) Add command: Query Sending query command: SET time_zone = '+00:00' 1 11862 <== Query#unknown name(0,,29) 1 11862 <== 19000000035345542074696d655f7a6f6e65203d20272b30303a303027 raw: 00000002400000001600110974696d655f7a6f6e65062b30303a3030020131 Trace at Connection.handlePacket (/app/project/egg-catalogbuy/node_modules/mysql2/lib/connection.js:419:17) at PacketParser.Connection.packetParser.p [as onPacket] (/app/project/egg-catalogbuy/node_modules/mysql2/lib/connection.js:72:12) at PacketParser.executeStart (/app/project/egg-catalogbuy/node_modules/mysql2/lib/packet_parser.js:75:16) at Socket.Connection.stream.on.data (/app/project/egg-catalogbuy/node_modules/mysql2/lib/connection.js:79:25) at emitOne (events.js:116:13) at Socket.emit (events.js:211:7) at addChunk (_stream_readable.js:263:12) at readableAddChunk (_stream_readable.js:250:11) at Socket.Readable.push (_stream_readable.js:208:10) at TCP.onread (net.js:594:20) 1 11862 ==> Query#unknown name(1,maybeOK,35) Trace at Packet.readLengthCodedNumberExt (/app/project/egg-catalogbuy/node_modules/mysql2/lib/packets/packet.js:229:13) at Packet.readLengthCodedNumber (/app/project/egg-catalogbuy/node_modules/mysql2/lib/packets/packet.js:191:17) at Packet.readLengthCodedString (/app/project/egg-catalogbuy/node_modules/mysql2/lib/packets/packet.js:358:22) at new ResultSetHeader (/app/project/egg-catalogbuy/node_modules/mysql2/lib/packets/resultset_header.js:71:52) at Query.resultsetHeader (/app/project/egg-catalogbuy/node_modules/mysql2/lib/commands/query.js:105:16) at Query.execute (/app/project/egg-catalogbuy/node_modules/mysql2/lib/commands/command.js:39:22) at Connection.handlePacket (/app/project/egg-catalogbuy/node_modules/mysql2/lib/connection.js:449:32) at PacketParser.Connection.packetParser.p [as onPacket] (/app/project/egg-catalogbuy/node_modules/mysql2/lib/connection.js:72:12) at PacketParser.executeStart (/app/project/egg-catalogbuy/node_modules/mysql2/lib/packet_parser.js:75:16) at Socket.Connection.stream.on.data (/app/project/egg-catalogbuy/node_modules/mysql2/lib/connection.js:79:25) at emitOne (events.js:116:13) at Socket.emit (events.js:211:7) at addChunk (_stream_readable.js:263:12) at readableAddChunk (_stream_readable.js:250:11) at Socket.Readable.push (_stream_readable.js:208:10) at TCP.onread (net.js:594:20) 2019-03-27 11:47:58,565 ERROR 18619 nodejs.unhandledExceptionError: Should not reach here: undefined at Packet.readLengthCodedNumberExt (/app/project/egg-catalogbuy/node_modules/mysql2/lib/packets/packet.js:230:11) at Packet.readLengthCodedNumber (/app/project/egg-catalogbuy/node_modules/mysql2/lib/packets/packet.js:191:17) at Packet.readLengthCodedString (/app/project/egg-catalogbuy/node_modules/mysql2/lib/packets/packet.js:358:22) at new ResultSetHeader (/app/project/egg-catalogbuy/node_modules/mysql2/lib/packets/resultset_header.js:71:52) at Query.resultsetHeader (/app/project/egg-catalogbuy/node_modules/mysql2/lib/commands/query.js:105:16) at Query.execute (/app/project/egg-catalogbuy/node_modules/mysql2/lib/commands/command.js:39:22) at Connection.handlePacket (/app/project/egg-catalogbuy/node_modules/mysql2/lib/connection.js:449:32) at PacketParser.Connection.packetParser.p [as onPacket] (/app/project/egg-catalogbuy/node_modules/mysql2/lib/connection.js:72:12) at PacketParser.executeStart (/app/project/egg-catalogbuy/node_modules/mysql2/lib/packet_parser.js:75:16) at Socket.Connection.stream.on.data (/app/project/egg-catalogbuy/node_modules/mysql2/lib/connection.js:79:25) at emitOne (events.js:116:13) at Socket.emit (events.js:211:7) at addChunk (_stream_readable.js:263:12) at readableAddChunk (_stream_readable.js:250:11) at Socket.Readable.push (_stream_readable.js:208:10) at TCP.onread (net.js:594:20) name: "unhandledExceptionError" pid: 18619 hostname: lhqcdz-uaes-ecom-nodejs0-ebaeef1e.novalocal

raw: 0000000200000000 Trace at Connection.handlePacket (/app/project/egg-catalogbuy/node_modules/mysql2/lib/connection.js:419:17) at PacketParser.Connection.packetParser.p [as onPacket] (/app/project/egg-catalogbuy/node_modules/mysql2/lib/connection.js:72:12) at PacketParser.executeStart (/app/project/egg-catalogbuy/node_modules/mysql2/lib/packet_parser.js:75:16) at Socket.Connection.stream.on.data (/app/project/egg-catalogbuy/node_modules/mysql2/lib/connection.js:79:25) at emitOne (events.js:116:13) at Socket.emit (events.js:211:7) at addChunk (_stream_readable.js:263:12) at readableAddChunk (_stream_readable.js:250:11) at Socket.Readable.push (_stream_readable.js:208:10) at TCP.onread (net.js:594:20) 0 8435 ==> ClientHandshake#unknown name(2,maybeOK,12) Add command: Query Sending query command: SET time_zone = '+00:00' 0 8435 <== Query#unknown name(0,,29) 0 8435 <== 19000000035345542074696d655f7a6f6e65203d20272b30303a303027 raw: 00000002400000001600110974696d655f7a6f6e65062b30303a3030020131 Trace at Connection.handlePacket (/app/project/egg-catalogbuy/node_modules/mysql2/lib/connection.js:419:17) at PacketParser.Connection.packetParser.p [as onPacket] (/app/project/egg-catalogbuy/node_modules/mysql2/lib/connection.js:72:12) at PacketParser.executeStart (/app/project/egg-catalogbuy/node_modules/mysql2/lib/packet_parser.js:75:16) at Socket.Connection.stream.on.data (/app/project/egg-catalogbuy/node_modules/mysql2/lib/connection.js:79:25) at emitOne (events.js:116:13) at Socket.emit (events.js:211:7) at addChunk (_stream_readable.js:263:12) at readableAddChunk (_stream_readable.js:250:11) at Socket.Readable.push (_stream_readable.js:208:10) at TCP.onread (net.js:594:20) 0 8435 ==> Query#unknown name(1,maybeOK,35) Trace at Packet.readLengthCodedNumberExt (/app/project/egg-catalogbuy/node_modules/mysql2/lib/packets/packet.js:229:13) at Packet.readLengthCodedNumber (/app/project/egg-catalogbuy/node_modules/mysql2/lib/packets/packet.js:191:17) at Packet.readLengthCodedString (/app/project/egg-catalogbuy/node_modules/mysql2/lib/packets/packet.js:358:22) at new ResultSetHeader (/app/project/egg-catalogbuy/node_modules/mysql2/lib/packets/resultset_header.js:71:52) at Query.resultsetHeader (/app/project/egg-catalogbuy/node_modules/mysql2/lib/commands/query.js:105:16) at Query.execute (/app/project/egg-catalogbuy/node_modules/mysql2/lib/commands/command.js:39:22) at Connection.handlePacket (/app/project/egg-catalogbuy/node_modules/mysql2/lib/connection.js:449:32) at PacketParser.Connection.packetParser.p [as onPacket] (/app/project/egg-catalogbuy/node_modules/mysql2/lib/connection.js:72:12) at PacketParser.executeStart (/app/project/egg-catalogbuy/node_modules/mysql2/lib/packet_parser.js:75:16) at Socket.Connection.stream.on.data (/app/project/egg-catalogbuy/node_modules/mysql2/lib/connection.js:79:25) at emitOne (events.js:116:13) at Socket.emit (events.js:211:7) at addChunk (_stream_readable.js:263:12) at readableAddChunk (_stream_readable.js:250:11) at Socket.Readable.push (_stream_readable.js:208:10) at TCP.onread (net.js:594:20) 2019-03-27 11:47:58,570 ERROR 18619 nodejs.unhandledExceptionError: Should not reach here: undefined at Packet.readLengthCodedNumberExt (/app/project/egg-catalogbuy/node_modules/mysql2/lib/packets/packet.js:230:11) at Packet.readLengthCodedNumber (/app/project/egg-catalogbuy/node_modules/mysql2/lib/packets/packet.js:191:17) at Packet.readLengthCodedString (/app/project/egg-catalogbuy/node_modules/mysql2/lib/packets/packet.js:358:22) at new ResultSetHeader (/app/project/egg-catalogbuy/node_modules/mysql2/lib/packets/resultset_header.js:71:52) at Query.resultsetHeader (/app/project/egg-catalogbuy/node_modules/mysql2/lib/commands/query.js:105:16) at Query.execute (/app/project/egg-catalogbuy/node_modules/mysql2/lib/commands/command.js:39:22) at Connection.handlePacket (/app/project/egg-catalogbuy/node_modules/mysql2/lib/connection.js:449:32) at PacketParser.Connection.packetParser.p [as onPacket] (/app/project/egg-catalogbuy/node_modules/mysql2/lib/connection.js:72:12) at PacketParser.executeStart (/app/project/egg-catalogbuy/node_modules/mysql2/lib/packet_parser.js:75:16) at Socket.Connection.stream.on.data (/app/project/egg-catalogbuy/node_modules/mysql2/lib/connection.js:79:25) at emitOne (events.js:116:13) at Socket.emit (events.js:211:7) at addChunk (_stream_readable.js:263:12) at readableAddChunk (_stream_readable.js:250:11) at Socket.Readable.push (_stream_readable.js:208:10) at TCP.onread (net.js:594:20) name: "unhandledExceptionError" pid: 18619 hostname: lhqcdz-uaes-ecom-nodejs0-ebaeef1e.novalocal

sidorares commented 5 years ago

Thanks @13349253469, this should be enough for me to investigate

13349253469 commented 5 years ago

Thanks @13349253469, this should be enough for me to investigate any progress?

13349253469 commented 5 years ago

Thanks @13349253469, this should be enough for me to investigate

Did you find the problem?

13349253469 commented 5 years ago

Thanks @13349253469, this should be enough for me to investigate Very anxious, still do not know how to solve

sidorares commented 5 years ago

@13349253469 the problem is in the driver code, I think I'll disable parsing of "track state change" flag and wait for somebody's clarification from mysql side ( ping @ruiquelhas ) for the protocol documentation

I'll try t release fix today

13349253469 commented 5 years ago

@13349253469 the problem is in the driver code, I think I'll disable parsing of "track state change" flag and wait for somebody's clarification from mysql side ( ping @ruiquelhas ) for the protocol documentation

I'll try t release fix today Can you tell me after posting the fix?

13349253469 commented 5 years ago

@13349253469 the problem is in the driver code, I think I'll disable parsing of "track state change" flag and wait for somebody's clarification from mysql side ( ping @ruiquelhas ) for the protocol documentation

I'll try t release fix today

could you please tell me the progress

13349253469 commented 5 years ago

@13349253469 the problem is in the driver code, I think I'll disable parsing of "track state change" flag and wait for somebody's clarification from mysql side ( ping @ruiquelhas ) for the protocol documentation

I'll try t release fix today

I am translating through a translator

13349253469 commented 5 years ago

@13349253469 the problem is in the driver code, I think I'll disable parsing of "track state change" flag and wait for somebody's clarification from mysql side ( ping @ruiquelhas ) for the protocol documentation

I'll try t release fix today

I'm in a hurry now

13349253469 commented 5 years ago

@13349253469 the problem is in the driver code, I think I'll disable parsing of "track state change" flag and wait for somebody's clarification from mysql side ( ping @ruiquelhas ) for the protocol documentation

I'll try t release fix today

Because one of my projects is going online

13349253469 commented 5 years ago

@13349253469 the problem is in the driver code, I think I'll disable parsing of "track state change" flag and wait for somebody's clarification from mysql side ( ping @ruiquelhas ) for the protocol documentation

I'll try t release fix today

Can you tell me the progress? Thank you

13349253469 commented 5 years ago

@13349253469 the problem is in the driver code, I think I'll disable parsing of "track state change" flag and wait for somebody's clarification from mysql side ( ping @ruiquelhas ) for the protocol documentation

I'll try t release fix today

Can you give me a reply?Thank you

13349253469 commented 5 years ago

@13349253469 the problem is in the driver code, I think I'll disable parsing of "track state change" flag and wait for somebody's clarification from mysql side ( ping @ruiquelhas ) for the protocol documentation

I'll try t release fix today

Can you tell me a quick solution?

13349253469 commented 5 years ago

@13349253469 the problem is in the driver code, I think I'll disable parsing of "track state change" flag and wait for somebody's clarification from mysql side ( ping @ruiquelhas ) for the protocol documentation

I'll try t release fix today

I don't know how to solve this problem

13349253469 commented 5 years ago

Can you give me a reply

Dieken commented 4 years ago

@13349253469 upgrade to latest mysql2(v2.1), it works.

sidorares commented 4 years ago

sorry @13349253469 for lack of feedback, hope that v2.1 did fix issue for you

Dieken commented 4 years ago

The cause is some mysql server provided by cloud providers returns strange reply for SET time_zone='+08:00', old mysql2 can't correctly parse it, I didn't bisect the commits which one fixed this issue.

wisdomspine commented 3 years ago

You need to ensure that node is using the system time and not fake timers. Add the below line immediately after your imports in the test file

jest.useRealTimers();

Or better still you can set timers to real in your jest config "timers":"real"

ghost commented 3 years ago

I am using mysql2 v2.2.5 which is the latest at time of posting and I still get this error. Any ideas why or how I may solve? I am connecting to a Wordpress database @ wpengine.com.

My trace is: 0 undefined ==> ClientHandshake#unknown name(0,,85) Server hello packet: capability flags:3254779903=(long password, found rows, long flag, connect with db, no schema, compress, odbc, local files, ignore space, protocol 41, interactive, ssl, ignore sigpipe, transactions, reserved, secure connection, multi statements, multi results, ps multi results, plugin auth, connect attrs, plugin auth lenenc client data, can handle expired passwords, session track, deprecate eof, ssl verify server cert, remember options) Sending handshake packet: flags:11203535=(long password, found rows, long flag, connect with db, odbc, local files, ignore space, protocol 41, ignore sigpipe, transactions, reserved, secure connection, multi results, plugin auth, plugin auth lenenc client data, session track) 0 8938665 <== ClientHandshake#unknown name(1,,94) 0 8938665 <== 5a000001cff3aa0000000000e000000000000000000000000000000000000000000000006d6f6d76310014854239714def0c80bedb98baa11491687bda113a77705f6d6f6d7631006d7973716c5f6e61746976655f70617373776f726400