Skip to content

Comments

Fix server-side client.end()#1376

Merged
rom1504 merged 1 commit intoPrismarineJS:masterfrom
h5mcbox:master
Mar 17, 2025
Merged

Fix server-side client.end()#1376
rom1504 merged 1 commit intoPrismarineJS:masterfrom
h5mcbox:master

Conversation

@h5mcbox
Copy link
Contributor

@h5mcbox h5mcbox commented Feb 22, 2025

To fix this error:

Disconnecting client because error TypeError [ERR_INVALID_ARG_TYPE]: SizeOf error for undefined : The "string" argument must be of type string or an instance of Buffer or ArrayBuffer. Received an instance of Object
    at Function.byteLength (node:buffer:766:11)
    at Object.string (eval at compile (~/test/node_modules/protodef/src/compiler.js:265:12), <anonymous>:78:25)
    at Object.packet_kick_disconnect (eval at compile (~/test/node_modules/protodef/src/compiler.js:265:12), <anonymous>:1110:27)
    at eval (eval at compile (~/test/node_modules/protodef/src/compiler.js:265:12), <anonymous>:2757:70)
    at packet (eval at compile (~/test/node_modules/protodef/src/compiler.js:265:12), <anonymous>:2842:9)
    at CompiledProtodef.sizeOf (~/test/node_modules/protodef/src/compiler.js:89:14)
    at e.message (~/test/node_modules/protodef/src/compiler.js:96:40)
    at tryCatch (~/test/node_modules/protodef/src/utils.js:50:16)
    at CompiledProtodef.createPacketBuffer (~/test/node_modules/protodef/src/compiler.js:96:20)
    at Serializer.createPacketBuffer (~/test/node_modules/protodef/src/serializer.js:12:23) {
  code: 'ERR_INVALID_ARG_TYPE',
  field: 'play.toClient'
}

Server code:

const minecraftProtocol = require("minecraft-protocol");
let server = minecraftProtocol.createServer({
  "online-mode": true,
  encryption: true,
  host: "0.0.0.0",
  port: 25566,
  maxPlayers: 0,
  version: false,
  fallbackVersion: "1.19.2",
  motd: "Foobar"
});
server.on('login', function (client) {
  console.log("login")
  client.end(`text`);
});

Join a nmp server which support chatPacketsUseNbtComponents using Minecraft 1.19.2

@rom1504 rom1504 merged commit 3bd4dc1 into PrismarineJS:master Mar 17, 2025
28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants