Open bentonjj opened 1 month ago
Can you reproduce this on another server or a vanilla server?
Yes, when using the standard bedrock server from minecraft.net still get the same crash, even in creative mode adding items to inventory:
C:\bedrock\node_modules\protodef\src\compiler.js:114
throw e
^
Error: Read error for undefined : array size is abnormally large, not reading: 16777216
at eval (eval at compile (C:\bedrock\node_modules\protodef\src\compiler.js:258:12), <anonymous>:342:37)
at Object.ItemExtraDataWithoutBlockingTick (eval at compile (C:\bedrock\node_modules\protodef\src\compiler.js:258:12), <anonymous>:351:9)
at eval (eval at compile (C:\bedrock\node_modules\protodef\src\compiler.js:258:12), <anonymous>:386:47)
at eval (eval at compile (C:\bedrock\node_modules\protodef\src\compiler.js:258:12), <anonymous>:388:17)
at eval (eval at compile (C:\bedrock\node_modules\protodef\src\compiler.js:258:12), <anonymous>:390:13)
at Object.ItemLegacy (eval at compile (C:\bedrock\node_modules\protodef\src\compiler.js:258:12), <anonymous>:392:9)
at eval (eval at compile (C:\bedrock\node_modules\protodef\src\compiler.js:258:12), <anonymous>:1606:48)
at eval (eval at compile (C:\bedrock\node_modules\protodef\src\compiler.js:258:12), <anonymous>:1611:17)
at eval (eval at compile (C:\bedrock\node_modules\protodef\src\compiler.js:258:12), <anonymous>:1614:13)
at eval (eval at compile (C:\bedrock\node_modules\protodef\src\compiler.js:258:12), <anonymous>:1616:11)
Node.js v18.20.4
I can get the proxy working again if I downgrade the minecraft-data package from 3.67.0 to 3.66.0 however I am limited to using the 1.20.80 and older client as if I upgrade to 1.21.2 I get a “Error: Unsupported version 1.21.2”. Updating minecraft-data to 3.67.0 causes the crash in all client versions.
The work around is to downgrade minecraft-data package to 3.66.0. Go to https://github.com/PrismarineJS/minecraft-data/releases and download the minecraft-data-3.66.0.zip file. Extract to node_modules\minecraft-data\minecraft-data. You will be limited to the 1.21.0 client and older as newer clients require minecraft-data 3.67.0 which causes the issue in all client versions.
Can you please set Error.stackTraceLimit = Infinity
at the top of your program and post the stack trace again?
This is the code:
Error.stackTraceLimit = Infinity const { Relay } = require('bedrock-protocol') const relay = new Relay({version: '1.20.80', host: '10.10.0.10', port: 4000, destination: { host: '10.10.0.10', port: 3000 }}) relay.listen() relay.on('connect', player => { console.log('New connection', player.connection.address) player.on('serverbound', ({ name, params }) => { }) })
Client is version 1.20.81 and server from minecraft.net is version 1.20.81.01
This is the output after the crash adding any item to inventory:
New connection 10.10.0.10/55385 C:\bedrock\node_modules\protodef\src\compiler.js:114 throw e ^
Error: Read error for undefined : array size is abnormally large, not reading: 16777216
at eval (eval at compile (C:\bedrock\node_modules\protodef\src\compiler.js:258:12),
Node.js v20.16.0
OK, please add some logging like this:
const fs = require('fs')
relay.on('connect', (player) => {
const file = fs.createWriteStream('log.txt')
player.downInLog = function (...e) {
file.write(JSON.stringify(e) + '\n')
}
})
and provide the log.txt file (either here or or http://gist.github.com). That should contain needed packet buffer information.
Sorry program simply exits when I connect and does not create any log file. This is what I'm using:
Error.stackTraceLimit = Infinity const { Relay } = require('bedrock-protocol') const relay = new Relay({version: '1.20.80', host: '10.10.0.10', port: 4000, destination: { host: '10.10.0.10', port: 3000 }}) relay.listen() relay.on('connect', player => { const file = fs.createWriteStream('log.txt') player.downInLog = function (...e) {file.write(JSON.stringify(e) + '\n')} console.log('New connection', player.connection.address) player.on('serverbound', ({ name, params }) => { }) })
This is the log:
This is the code I'm using:
BigInt.prototype.toJSON = function() { return this.toString() } const { Relay } = require('bedrock-protocol') const relay = new Relay({version: '1.20.80', host: '10.10.0.10', port: 4000, destination: { host: '10.10.0.10', port: 3000 }}) relay.listen() const fs = require('fs')
relay.on('connect', (player) => {
const file = fs.createWriteStream('log.txt') player.downInLog = function (...e) { file.write(JSON.stringify(e) + '\n') } })
I had to add the first line to resolve a "TypeError: Do not know how to serialize a BigInt"
You can pick up items, take items from chests, and use /give command with no crash. Crash happens when crafting an item on crafting table or adding item to inventory from creative mode.
Looking into the crafting issue, seems a bit odd that the buffer is using craft_creative as opposed to auto which was updated.
I can separately confirm the issue with the movement correction packet, that is missing a field since 1.20.80.
Ah wow, crafting issue seems to be caused by a bug in protodef compiler's codegen. Anonymous containers with switches have bad code generation.
Will be fixed by https://github.com/ProtoDef-io/node-protodef/pull/159
Would be great if people could test out the above PR.
Movement correction issue fixed upstream with #522.
But again if anyone could test above PR in ProtoDef that would be great.
Get the below crash crafting anything on Bedrock servers when connected with proxy. Tried 1.20.80 and 1.21.2 clients, even when using basic proxy script example code:
C:\bedrock\node_modules\protodef\src\compiler.js:114 throw e ^
Error: Read error for undefined : array size is abnormally large, not reading: 16777216 at eval (eval at compile (C:\bedrock\node_modules\protodef\src\compiler.js:258:12),:342:37)
at Object.ItemExtraDataWithoutBlockingTick (eval at compile (C:\bedrock\node_modules\protodef\src\compiler.js:258:12), :351:9)
at eval (eval at compile (C:\bedrock\node_modules\protodef\src\compiler.js:258:12), :386:47)
at eval (eval at compile (C:\bedrock\node_modules\protodef\src\compiler.js:258:12), :388:17)
at eval (eval at compile (C:\bedrock\node_modules\protodef\src\compiler.js:258:12), :390:13)
at Object.ItemLegacy (eval at compile (C:\bedrock\node_modules\protodef\src\compiler.js:258:12), :392:9)
at eval (eval at compile (C:\bedrock\node_modules\protodef\src\compiler.js:258:12), :1577:48)
at eval (eval at compile (C:\bedrock\node_modules\protodef\src\compiler.js:258:12), :1582:17)
at eval (eval at compile (C:\bedrock\node_modules\protodef\src\compiler.js:258:12), :1585:13)
at eval (eval at compile (C:\bedrock\node_modules\protodef\src\compiler.js:258:12), :1587:11)
Node.js v18.20.4