Skip to content

Commit af0fcfa

Browse files
rom1504claude
andcommitted
Use gunzipSync to avoid uncaught async zlib errors
Node's async zlib.gunzip creates C++ handles that can fire errors after JS listeners are removed during teardown. gunzipSync completes immediately with no lingering handles. See nodejs/node#62325, nodejs/node#61202, nodejs/node#43868 Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
1 parent 2a6c5e9 commit af0fcfa

3 files changed

Lines changed: 3 additions & 6 deletions

File tree

nbt.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,9 @@ const hasBedrockLevelHeader = (data) =>
7474
async function parseAs (data, type, options = {}) {
7575
if (!(data instanceof Buffer)) throw new Error('Invalid argument: `data` must be a Buffer object')
7676
if (hasGzipHeader(data)) {
77-
data = await new Promise((resolve, reject) => {
78-
zlib.gunzip(data, (error, uncompressed) => {
79-
if (error) reject(error)
80-
else resolve(uncompressed)
81-
})
82-
})
77+
// Use sync to avoid uncaught async zlib errors from Node's C++ binding
78+
// race condition during teardown. See nodejs/node#62325, nodejs/node#61202
79+
data = zlib.gunzipSync(data)
8380
}
8481

8582
protos[type].setVariable('noArraySizeCheck', options.noArraySizeCheck)

out-block-states.nbt

958 KB
Binary file not shown.

out-le-level.dat

483 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)