Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix server-side client.end() #1376

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

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

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.

2 participants