PrismarineJS / prismarine-provider-anvil

Anvil Storage Provider implementation.
13 stars 24 forks source link

Unhandled promise rejection when writing world to disk #65

Open IceTank opened 1 year ago

IceTank commented 1 year ago

Every once in a while I get this error

RangeError: Write error for undefined : The value of "value" is out of range. It must be >= -128 and <= 127. Received 156
    at new NodeError (node:internal/errors:388:5)
    at writeU_Int8 (node:internal/buffer:738:11)
    at Buffer.writeInt8 (node:internal/buffer:869:10)
    at Object.writer [as i8] (/project_path/node_modules/protodef/src/datatypes/numeric.js:97:25)
    at Object.byteArray (eval at compile (/project_path/node_modules/protodef/src/compiler.js:258:12), <anonymous>:56:26)
    at Object.nbtSwitch (eval at compile (/project_path/node_modules/protodef/src/compiler.js:258:12), <anonymous>:99:49)
    at Object.nbt (eval at compile (/project_path/node_modules/protodef/src/compiler.js:258:12), <anonymous>:114:31)
    at Object.compound (eval at compile (/project_path/node_modules/protodef/src/compiler.js:258:12), <anonymous>:5:26)
    at Object.nbtSwitch (eval at compile (/project_path/node_modules/protodef/src/compiler.js:258:12), <anonymous>:102:47)
    at Object.nbt (eval at compile (/project_path/node_modules/protodef/src/compiler.js:258:12), <anonymous>:114:31)
    at Object.compound (eval at compile (/project_path/node_modules/protodef/src/compiler.js:258:12), <anonymous>:5:26)
    at Object.nbtSwitch (eval at compile (/project_path/node_modules/protodef/src/compiler.js:258:12), <anonymous>:102:47)
    at nbt (eval at compile (/project_path/node_modules/protodef/src/compiler.js:258:12), <anonymous>:114:31)
    at CompiledProtodef.write (/project_path/node_modules/protodef/src/compiler.js:76:12)
    at e.message (/project_path/node_modules/protodef/src/compiler.js:102:25)
    at tryCatch (/project_path/node_modules/protodef/src/utils.js:50:16)
    at CompiledProtodef.createPacketBuffer (/project_path/node_modules/protodef/src/compiler.js:102:5)
    at Object.writeUncompressed (/project_path/node_modules/prismarine-nbt/nbt.js:36:24)
    at RegionFile._write (/project_path/node_modules/prismarine-provider-anvil/src/region.js:151:34) {
  code: 'ERR_OUT_OF_RANGE'
}

I don't know what might be causing this. Any suggestions on how to debug this issue or what might be causing it? This is running on a 1.12.2 paper server.

IceTank commented 1 year ago

Looks like this issue is from trying to write Biomes that have an id bigger then 127. For instance in 1.12.2 swamp hills have the id 134 while prismarine-nbt is trying to write the Biome id to a byte array made out of i8 instead of ui8. I am not sure how this could be fixed as the byte array is probably used for other stuff as well that might break when changing it to a ui8?