oven-sh / bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
https://bun.sh
Other
73.6k stars 2.72k forks source link

bun error: Partially Length-prefixed Bytes unmatched lengths; error not present when using node #14243

Open tkurze opened 1 week ago

tkurze commented 1 week ago

What version of Bun is running?

1.1.29+6d43b3662

What platform is your computer?

Darwin 24.0.0 arm64 arm

What steps can reproduce the bug?

Start a new project, add mssql as dependency and query a (big enough) table; like so: SELECT * from .

const pool = await sql.connect(sqlConfig)
const query = `SELECT * from ${process.env.MSSQL_TABLE}`
const result = await pool.query(query)
console.log(result.recordset.length)

If the table has enough content (in my case only about a 1000 rows) I always encounter the following problem. The problem does not occur when using node.

error: Partially Length-prefixed Bytes unmatched lengths : expected 30, but got 352 bytes at [...]/node_modules/tedious/lib/value-parser.js:659:17 at readPLPStream ([...]/node_modules/tedious/lib/value-parser.js:750:23) at [...]/node_modules/tedious/lib/token/row-token-parser.js:12:348 654 | parser.position += chunkLength; 655 | currentLength += chunkLength; 656 | } 657 | if (expectedLength !== UNKNOWN_PLP_LEN) { 658 | if (currentLength !== Number(expectedLength)) { 659 | throw new Error('Partially Length-prefixed Bytes unmatched lengths : expected ' + expectedLength + ', but got ' + currentLength + ' bytes'); ^ error: Partially Length-prefixed Bytes unmatched lengths : expected 836, but got 161 bytes at [...]/node_modules/tedious/lib/value-parser.js:659:17 at readPLPStream ([...]/node_modules/tedious/lib/value-parser.js:750:23) at [...]/node_modules/tedious/lib/token/row-token-parser.js:12:348

What is the expected behavior?

No error should occur.

What do you see instead?

An error message: error: Partially Length-prefixed Bytes unmatched lengths : expected 836, but got 161 bytes

Additional information

Node version: v22.9.0

ptrxyz commented 1 week ago

I also ran into this. There is no way to determine if this error happens so it makes it pretty much impossible to use MS SQL with bun. :/ Considering that this is a problem with reading streams over the net, could this also be related to #14249?