mineflayer: unexpected end of file [FIX]

I just figure out the zlib issue with some packet on some servers xD. I just look online for the sharing compressed data chunks and I figured the issue out. If this is still alive I will post it there.

That was the issue:

problem inflating chunk
uncompressed length 978
compressed length 744
hex d207789c04c0fb52e2581300f0a99a222120e3f7285c744aff4441148d950f32ce6ad556aa9334396dce85ed3e07495e68df635f6cf7b78ae7cb3e68946ff17cd9078df2fd9fbfcb6fdf23d05fd0c9c0e209f9df3fc7bf9850e70a8fec460d944c0ab8f6c991fa1e0ec4385ad7dcada5020d71ca1fee44f5585aaa0d703b9b2f068f802c835df05e0619196a265ba7acedee1508de2ea20d3afea41f3ba4d2055b620bd6fa71aef0c589cfe0487171cf533b95c833a8a32437c50b956557dc4cf6470da236609067b38b3cb0d768c04ea7d7d141137bba3464a866689c95dbdbc5ed450ae29177a09cd38327916e3ba943d58a860e79365f0c1fc174a5b398e40c1a99bc8a0c812d5d9c83a1ec948d0c59ac098cb3c33bf490822d22f8cb2be4e466b5ddb9aa959b787f425b9cd465ae70030639258b775c445fce92866859bb12cf83654fc0c3e7f56e9fa7cbd7d1abb3765964a74c922db5f8a1c036c30df53ddaf77cbc75558b2988471eed499f903fc85651a576bf5e3e062f0ac45fee2bf505dce70a57ae69dce899b8ec526ce08f510aecc9d2799d45a50ea50ed13b786860f4466d0b77d4b690ac406b90ec940d5708f54368ab894155d32758294a763f0c59ac180efe0b787e3d7c462bc8ffcf87cfae79200b3ad12e68174208832cd4d85d661a3ab2cd83636fc9e3c52754adafe14472358d5ebb33053334c81a8bd97cb2ba4f31771bf4ab9593e481b1466e801328814b6492f1d242030659ee7683fdcb52bf0ee538b51bfcf9337aed6a8d78f1e4fb14dd57a6a193e41eac7f249fe278eb2ccaded21139da06d428d179072ee8e437dc2bb2ef61fe6385726474553882f5182dcbb2cfd3cb3b2792822d66d3abc5d56c1e93eec46c5d9282f650baee263650d71dcae45cbaf327b45801f3ec7fbf9d3e6450b59986ae2fdef3248323d50c2dc61b6c57649bf82db0c756c66b5da4502957cc170983982068afc76b8d9567aad6a52416bcea8a83eee237d4cfae97d1933d3836603d2629e9b6db7b34ff010000ffff
inflate 789c04c0fb52e2581300f0a99a222120e3f7285c744aff4441148d950f32ce6ad556aa9334396dce85ed3e07495e68df635f6cf7b78ae7cb3e68946ff17cd9078df2fd9fbfcb6fdf23d05fd0c9c0e209f9df3fc7bf9850e70a8fec460d944c0ab8f6c991fa1e0ec4385ad7dcada5020d71ca1fee44f5585aaa0d703b9b2f068f802c835df05e0619196a265ba7acedee1508de2ea20d3afea41f3ba4d2055b620bd6fa71aef0c589cfe0487171cf533b95c833a8a32437c50b956557dc4cf6470da236609067b38b3cb0d768c04ea7d7d141137bba3464a866689c95dbdbc5ed450ae29177a09cd38327916e3ba943d58a860e79365f0c1fc174a5b398e40c1a99bc8a0c812d5d9c83a1ec948d0c59ac098cb3c33bf490822d22f8cb2be4e466b5ddb9aa959b787f425b9cd465ae70030639258b775c445fce92866859bb12cf83654fc0c3e7f56e9fa7cbd7d1abb3765964a74c922db5f8a1c036c30df53ddaf77cbc75558b2988471eed499f903fc85651a576bf5e3e062f0ac45fee2bf505dce70a57ae69dce899b8ec526ce08f510aecc9d2799d45a50ea50ed13b786860f4466d0b77d4b690ac406b90ec940d5708f54368ab894155d32758294a763f0c59ac180efe0b787e3d7c462bc8ffcf87cfae79200b3ad12e68174208832cd4d85d661a3ab2cd83636fc9e3c52754adafe14472358d5ebb33053334c81a8bd97cb2ba4f31771bf4ab9593e481b1466e801328814b6492f1d242030659ee7683fdcb52bf0ee538b51bfcf9337aed6a8d78f1e4fb14dd57a6a193e41eac7f249fe278eb2ccaded21139da06d428d179072ee8e437dc2bb2ef61fe6385726474553882f5182dcbb2cfd3cb3b2792822d66d3abc5d56c1e93eec46c5d9282f650baee263650d71dcae45cbaf327b45801f3ec7fbf9d3e6450b59986ae2fdef3248323d50c2dc61b6c57649bf82db0c756c66b5da4502957cc170983982068afc76b8d9567aad6a52416bcea8a83eee237d4cfae97d1933d3836603d2629e9b6db7b34ff010000ffff
{ Error: unexpected end of file
    at Inflate.zlibOnError (zlib.js:153:15) errno: -5, code: 'Z_BUF_ERROR' }

If you need the fix let me know.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 17 (6 by maintainers)

Most upvoted comments

Ok. The issue is in the minecraft-protocol module, in compression.js line 55.

You need to replace this:

zlib.inflate(chunk.slice(size), (err, newBuf) => {

to this:

zlib.unzip(chunk.slice(size), { finishFlush: zlib.constants.Z_SYNC_FLUSH }, (err, newBuf) => { /** Fix by lefela4. */

The problem happen when the packet end with the byte 0000ffff. I made some rechearch and I figured out the those byte are made for sharing deflate-compressed data chunks between streaming HTTP clients. However, from my understanding of DEFLATE/zlib, you can instead send Z_FULL_FLUSH 0x0000FFFF bytes to reset the stream which should serve the same effect of individually decompressible chunks. I will sumbit a pull request for the issue. Hope my explanation are good! Have a good day 😃

My changes-> https://github.com/PrismarineJS/node-minecraft-protocol/compare/master...lefela4:patch-1 My pull -> https://github.com/PrismarineJS/node-minecraft-protocol/pull/603