RangeError [ERR_OUT_OF_RANGE]: The value of "offset" is out of range.
RangeError [ERR_OUT_OF_RANGE]: The value of "offset" is out of range. It must be >= 0 and <= 19. Received 20 at boundsError (internal/buffer.js:49:9) at Uint8Array.readUInt32LE (internal/buffer.js:105:5) at Packet.readInt32 (/workspace/node_modules/mysql2/lib/packets/packet.js:103:24) at Packet.readLengthCodedNumberExt (/workspace/node_modules/mysql2/lib/packets/packet.js:211:20) at Packet.readLengthCodedNumber (/workspace/node_modules/mysql2/lib/packets/packet.js:188:17) at Packet.readLengthCodedString (/workspace/node_modules/mysql2/lib/packets/packet.js:355:22) at new ResultSetHeader (/workspace/node_modules/mysql2/lib/packets/resultset_header.js:59:24) at Execute.resultsetHeader (/workspace/node_modules/mysql2/lib/commands/query.js:104:16) at Execute.execute (/workspace/node_modules/mysql2/lib/commands/command.js:39:22) at Connection.handlePacket (/workspace/node_modules/mysql2/lib/connection.js:449:32) at PacketParser.Connection.packetParser.p [as onPacket] (/workspace/node_modules/mysql2/lib/connection.js:72:12) at PacketParser.executeStart (/workspace/node_modules/mysql2/lib/packet_parser.js:75:16) at Socket.Connection.stream.on.data (/workspace/node_modules/mysql2/lib/connection.js:79:25) at Socket.emit (events.js:198:13) at addChunk (_stream_readable.js:288:12) at readableAddChunk (_stream_readable.js:269:11) at Socket.Readable.push (_stream_readable.js:224:10) at TCP.onStreamRead [as onread] (internal/stream_base_commons.js:94:17)
is there a simple way to reproduce this @Degfy ?
no, it's random. i do not find the regular pattern. I guess what special characters are stored in mysql.
when i use utf8mb4. the error is:
Trace
at Packet.readLengthCodedNumberExt (/workspace/node_modules/mysql2/lib/packets/packet.js:226:13)
at Packet.readLengthCodedNumber (/workspace/node_modules/mysql2/lib/packets/packet.js:188:17)
at Packet.readLengthCodedString (/workspace/node_modules/mysql2/lib/packets/packet.js:355:22)
at new ResultSetHeader (/workspace/node_modules/mysql2/lib/packets/resultset_header.js:59:24)
at Query.resultsetHeader (/workspace/node_modules/mysql2/lib/commands/query.js:104:16)
at Query.execute (/workspace/node_modules/mysql2/lib/commands/command.js:39:22)
at Connection.handlePacket (/workspace/node_modules/mysql2/lib/connection.js:449:32)
at PacketParser.Connection.packetParser.p [as onPacket] (/workspace/node_modules/mysql2/lib/connection.js:72:12)
at PacketParser.executeStart (/workspace/node_modules/mysql2/lib/packet_parser.js:75:16)
at Socket.Connection.stream.on.data (/workspace/node_modules/mysql2/lib/connection.js:79:25)
at Socket.emit (events.js:198:13)
at addChunk (_stream_readable.js:288:12)
at readableAddChunk (_stream_readable.js:269:11)
at Socket.Readable.push (_stream_readable.js:224:10)
at TCP.onStreamRead [as onread] (internal/stream_base_commons.js:94:17)
Error: Should not reach here: 255
at Packet.readLengthCodedNumberExt (/workspace/node_modules/mysql2/lib/packets/packet.js:227:11)
at Packet.readLengthCodedNumber (/workspace/node_modules/mysql2/lib/packets/packet.js:188:17)
at Packet.readLengthCodedString (/workspace/node_modules/mysql2/lib/packets/packet.js:355:22)
at new ResultSetHeader (/workspace/node_modules/mysql2/lib/packets/resultset_header.js:59:24)
at Query.resultsetHeader (/workspace/node_modules/mysql2/lib/commands/query.js:104:16)
at Query.execute (/workspace/node_modules/mysql2/lib/commands/command.js:39:22)
at Connection.handlePacket (/workspace/node_modules/mysql2/lib/connection.js:449:32)
at PacketParser.Connection.packetParser.p [as onPacket] (/workspace/node_modules/mysql2/lib/connection.js:72:12)
at PacketParser.executeStart (/workspace/node_modules/mysql2/lib/packet_parser.js:75:16)
at Socket.Connection.stream.on.data (/workspace/node_modules/mysql2/lib/connection.js:79:25)
at Socket.emit (events.js:198:13)
at addChunk (_stream_readable.js:288:12)
at readableAddChunk (_stream_readable.js:269:11)
at Socket.Readable.push (_stream_readable.js:224:10)
at TCP.onStreamRead [as onread] (internal/stream_base_commons.js:94:17)
@sidorares
i forked the repo, change the code like this:

there is the console info when program crashed:
RangeError [ERR_OUT_OF_RANGE]: The value of "offset" is out of range. It must be >= 0 and <= 27. Received 28
at boundsError (internal/buffer.js:49:9)
at Uint8Array.readUInt32LE (internal/buffer.js:105:5)
at Packet.readInt32 (/workspace/node_modules/mysql2-degfy-test/lib/packets/packet.js:103:24)
at Packet.readLengthCodedNumberExt (/workspace/node_modules/mysql2-degfy-test/lib/packets/packet.js:211:20)
at Packet.readLengthCodedNumber (/workspace/node_modules/mysql2-degfy-test/lib/packets/packet.js:188:17)
at Packet.readLengthCodedString (/workspace/node_modules/mysql2-degfy-test/lib/packets/packet.js:355:22)
at new ResultSetHeader (/workspace/node_modules/mysql2-degfy-test/lib/packets/resultset_header.js:59:24)
at Query.resultsetHeader (/workspace/node_modules/mysql2-degfy-test/lib/commands/query.js:104:16)
at Query.execute (/workspace/node_modules/mysql2-degfy-test/lib/commands/command.js:39:22)
at Connection.handlePacket (/workspace/node_modules/mysql2-degfy-test/lib/connection.js:459:32)
at PacketParser.Connection.packetParser.p [as onPacket] (/workspace/node_modules/mysql2-degfy-test/lib/connection.js:72:12)
at PacketParser.executeStart (/workspace/node_modules/mysql2-degfy-test/lib/packet_parser.js:75:16)
at Socket.Connection.stream.on.data (/workspace/node_modules/mysql2-degfy-test/lib/connection.js:80:27)
at Socket.emit (events.js:198:13)
at addChunk (_stream_readable.js:288:12)
at readableAddChunk (_stream_readable.js:269:11)
at Socket.Readable.push (_stream_readable.js:224:10)
at TCP.onStreamRead [as onread] (internal/stream_base_commons.js:94:17)
<Buffer 1b 00 00 01 00 01 fe 65 96 fc 02 00 00 00 00 03 40 00 00 00 0a 14 08 fe 60 63 9b 05 00 00 00>
�e�� @
�`c�
RangeError [ERR_OUT_OF_RANGE]: The value of "offset" is out of range. It must be >= 0 and <= 27. Received 28
at boundsError (internal/buffer.js:49:9)
at Uint8Array.readUInt32LE (internal/buffer.js:105:5)
at Packet.readInt32 (/workspace/node_modules/mysql2-degfy-test/lib/packets/packet.js:103:24)
at Packet.readLengthCodedNumberExt (/workspace/node_modules/mysql2-degfy-test/lib/packets/packet.js:211:20)
at Packet.readLengthCodedNumber (/workspace/node_modules/mysql2-degfy-test/lib/packets/packet.js:188:17)
at Packet.readLengthCodedString (/workspace/node_modules/mysql2-degfy-test/lib/packets/packet.js:355:22)
at new ResultSetHeader (/workspace/node_modules/mysql2-degfy-test/lib/packets/resultset_header.js:59:24)
at Query.resultsetHeader (/workspace/node_modules/mysql2-degfy-test/lib/commands/query.js:104:16)
at Query.execute (/workspace/node_modules/mysql2-degfy-test/lib/commands/command.js:39:22)
at Connection.handlePacket (/workspace/node_modules/mysql2-degfy-test/lib/connection.js:459:32)
at PacketParser.Connection.packetParser.p [as onPacket] (/workspace/node_modules/mysql2-degfy-test/lib/connection.js:72:12)
at PacketParser.executeStart (/workspace/node_modules/mysql2-degfy-test/lib/packet_parser.js:75:16)
at Socket.Connection.stream.on.data (/workspace/node_modules/mysql2-degfy-test/lib/connection.js:80:27)
at Socket.emit (events.js:198:13)
at addChunk (_stream_readable.js:288:12)
at readableAddChunk (_stream_readable.js:269:11)
at Socket.Readable.push (_stream_readable.js:224:10)
at TCP.onStreamRead [as onread] (internal/stream_base_commons.js:94:17)
Thanks @Degfy , this is really helpful, I should be able to debug it now
another error:
<Buffer 15 00 00 01 00 01 fc 41 0d 03 40 00 00 00 0a 14 08 fe 1a 54 1c 06 00 00 00>
�A
@
�T
RangeError [ERR_OUT_OF_RANGE]: The value of "offset" is out of range. It must be >= 0 and <= 21. Received 22
at boundsError (internal/buffer.js:49:9)
at Uint8Array.readUInt32LE (internal/buffer.js:105:5)
at Packet.readInt32 (/workspace/node_modules/mysql2-degfy-test/lib/packets/packet.js:103:24)
at Packet.readLengthCodedNumberExt (/workspace/node_modules/mysql2-degfy-test/lib/packets/packet.js:211:20)
at Packet.readLengthCodedNumber (/workspace/node_modules/mysql2-degfy-test/lib/packets/packet.js:188:17)
at Packet.readLengthCodedString (/workspace/node_modules/mysql2-degfy-test/lib/packets/packet.js:355:22)
at new ResultSetHeader (/workspace/node_modules/mysql2-degfy-test/lib/packets/resultset_header.js:59:24)
at Execute.resultsetHeader (/workspace/node_modules/mysql2-degfy-test/lib/commands/query.js:104:16)
at Execute.execute (/workspace/node_modules/mysql2-degfy-test/lib/commands/command.js:39:22)
at Connection.handlePacket (/workspace/node_modules/mysql2-degfy-test/lib/connection.js:459:32)
at PacketParser.Connection.packetParser.p [as onPacket] (/workspace/node_modules/mysql2-degfy-test/lib/connection.js:72:12)
at PacketParser.executeStart (/workspace/node_modules/mysql2-degfy-test/lib/packet_parser.js:75:16)
at Socket.Connection.stream.on.data (/workspace/node_modules/mysql2-degfy-test/lib/connection.js:80:27)
at Socket.emit (events.js:198:13)
at addChunk (_stream_readable.js:288:12)
at readableAddChunk (_stream_readable.js:269:11)
at Socket.Readable.push (_stream_readable.js:224:10)
at TCP.onStreamRead [as onread] (internal/stream_base_commons.js:94:17)
Hi @Degfy , do you know what is the server version?
Packet tries to read 8 bytes of data after 0xfe at the end, but there is only 7 available
If version is 3.22 or earlier this might be caused by
https://dev.mysql.com/doc/internals/en/integer.html#packet-Protocol::LengthEncodedInteger
Note Up to MySQL 3.22, 0xfe was followed by a 4-byte integer.
it's 8.0.13. @sidorares

Looks like "session track change information" in resultset header parser is not handled correctly
Some bookmarks for me:
Enums: https://github.com/mysql/mysql-server/blob/4869291f7ee258e136ef03f5a50135fe7329ffb9/include/mysql_com.h#L960-L977
Parser code in libmysqlclient: https://github.com/mysql/mysql-server/blob/4869291f7ee258e136ef03f5a50135fe7329ffb9/sql-common/client.cc#L8045-L8088
The issue is that session track type ( 0x14 ) is outside allowed known types ( 0..5 ) and has to be handled differently
Hi,@sidorares There is more error buffers: <Buffer 13 00 00 01 00 01 00 02 40 00 00 00 0a 14 08 fe 18 25 e7 06 00 00 00>
The buffer is too long to show with console.log, so i saved as files. It looks like you are right. So, can you take the time to fix it as soon as possible? It has already tortured us for a week.
/var # ls
cache local run
empty lock spool
error.1565002172438.data log tmp
lib opt
/var # cat error.1565002172438.data
9@&Records: 1 Duplicates: 0 Warnings: 0
�ZW�/var #
/var # hexdump error.1565002172438.data
0000000 0039 0100 0100 0200 0040 2600 6552 6f63
0000010 6472 3a73 3120 2020 7544 6c70 6369 7461
0000020 7365 203a 2030 5720 7261 696e 676e 3a73
0000030 3020 140a ff08 575a 06e9 0000 0000
000003d
/var #
/var # ls
cache lib opt
empty local run
error.1564990584930.data lock spool
error.1565002166869.data log tmp
/var # hexdump error.1564990584930.data
0000000 0039 0100 0100 0200 0040 2600 6552 6f63
0000010 6472 3a73 3120 2020 7544 6c70 6369 7461
0000020 7365 203a 2030 5720 7261 696e 676e 3a73
0000030 3020 140a ff08 6540 06e5 0000 0000
000003d
/var # hexdump error.1565002166869.data
0000000 0039 0100 0100 0200 0040 2600 6552 6f63
0000010 6472 3a73 3120 2020 7544 6c70 6369 7461
0000020 7365 203a 2030 5720 7261 696e 676e 3a73
0000030 3020 140a ff08 5716 06e9 0000 0000
000003d
/var #
Thanks for extra data!
Could you also send me server capability flags? You can see it if you connect with debug: true option.
This is simple test script I'm using to quickly reproduce the issue (as you can see I assumed flags to be 8389120):
const buf = Buffer.from(
`1b 00 00 01
00
01 fe 65 96 fc 02 00 00 00 00 03 40 00 00 00 0a 14 08 fe 60 63 9b 05 00 00 00
`
.split(/[ \n]+/)
.join(''),
'hex'
);
const Packet = require('./lib/packets/packet');
const p = new Packet(0, buf, 0, buf.length);
const ResultSetHeader = require('./lib/packets/resultset_header.js');
const conn = {
config: {},
serverEncoding: 'utf8',
_handshakePacket: {
capabilityFlags: 512 + 8388608
}
};
const rs = new ResultSetHeader(p, conn);
console.log(rs);
So, can you take the time to fix it as soon as possible? It has already tortured us for a week.
yeah, I think I can do that today or maybe tomorrow
Server hello packet: capability flags:3288334335=(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: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 40642 <== ClientHandshake#unknown name(1,,80) 0 40642 <== 4c000001cdf38200000000002d000000000000000000000000000000000000000000000074657374646275736572001402b5775f282dc70a2cf372b2f1dd67125839ae936162635f6369735f64657600 raw: 000000024000000023010c0b6162635f6369735f6465760509085f5f5f5f5f5f5f5f1408e02dc10107000000
hi,@sidorares Does it mean that I can temporarily suppress this error as long as it is disabled with option:
{
flags: '-SESSION_TRACK',
}
most likely ( if config parser handles this correctly ), was going to suggest that as short term solution
most likely ( if config parser handles this correctly ), was going to suggest that as short term solution
It's useful. Thank you very much, @sidorares. Waiting for your new release.
hi,@sidorares Does it mean that I can temporarily suppress this error as long as it is disabled with option:
{ flags: '-SESSION_TRACK', }
hi I have same issue, how to disable
{ flags: '-SESSION_TRACK', }