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

writeBook() function seems to be buggy/broken #3204

Open
1 task done
AmeliaYeah opened this issue Sep 27, 2023 · 5 comments · May be fixed by #3373
Open
1 task done

writeBook() function seems to be buggy/broken #3204

AmeliaYeah opened this issue Sep 27, 2023 · 5 comments · May be fixed by #3373
Labels
possible bug Stage1 just created by someone new to the project, we don't know yet if it deserves an implementation / a f

Comments

@AmeliaYeah
Copy link

AmeliaYeah commented Sep 27, 2023

  • The FAQ doesn't contain a resolution to my issue

Versions

  • mineflayer: 4.14.0
  • server: vanilla 1.19.3
  • node: 20.7.0

Detailed description of a problem

When utilizing the writeBook API call, an error message seems to pop up that happens regardless of the pages I input. The current code is here:

bot.writeBook(book.slot, extras.format_txt_to_book(txt, is_bedrock)).then(() => {
    //some other stuff that doesnt execute
}).catch((reason) => {
    //this also does not execute, which is strange, because an error message pops up in the console
})

The error message that always pops up is this:

TypeError: Serialization error for play.toServer : SizeOf error for undefined : Cannot read properties of undefined (reading 'length')
    at eval (eval at compile (/home/amelia/mcbot/node_modules/protodef/src/compiler.js:258:12), <anonymous>:712:39)
    at Object.packet_edit_book (eval at compile (/home/amelia/mcbot/node_modules/protodef/src/compiler.js:258:12), <anonymous>:717:9)
    at eval (eval at compile (/home/amelia/mcbot/node_modules/protodef/src/compiler.js:258:12), <anonymous>:1259:58)
    at packet (eval at compile (/home/amelia/mcbot/node_modules/protodef/src/compiler.js:258:12), <anonymous>:1299:9)
    at CompiledProtodef.sizeOf (/home/amelia/mcbot/node_modules/protodef/src/compiler.js:89:14)
    at e.message (/home/amelia/mcbot/node_modules/protodef/src/compiler.js:96:40)
    at tryCatch (/home/amelia/mcbot/node_modules/protodef/src/utils.js:50:16)
    at CompiledProtodef.createPacketBuffer (/home/amelia/mcbot/node_modules/protodef/src/compiler.js:96:20)
    at Serializer.createPacketBuffer (/home/amelia/mcbot/node_modules/protodef/src/serializer.js:12:23)
    at Serializer._transform (/home/amelia/mcbot/node_modules/protodef/src/serializer.js:18:18) {
  field: 'play.toServer'
}
TypeError: Serialization error for play.toServer : SizeOf error for undefined : Cannot read properties of undefined (reading 'length')
    at eval (eval at compile (/home/amelia/mcbot/node_modules/protodef/src/compiler.js:258:12), <anonymous>:712:39)
    at Object.packet_edit_book (eval at compile (/home/amelia/mcbot/node_modules/protodef/src/compiler.js:258:12), <anonymous>:717:9)
    at eval (eval at compile (/home/amelia/mcbot/node_modules/protodef/src/compiler.js:258:12), <anonymous>:1259:58)
    at packet (eval at compile (/home/amelia/mcbot/node_modules/protodef/src/compiler.js:258:12), <anonymous>:1299:9)
    at CompiledProtodef.sizeOf (/home/amelia/mcbot/node_modules/protodef/src/compiler.js:89:14)
    at e.message (/home/amelia/mcbot/node_modules/protodef/src/compiler.js:96:40)
    at tryCatch (/home/amelia/mcbot/node_modules/protodef/src/utils.js:50:16)
    at CompiledProtodef.createPacketBuffer (/home/amelia/mcbot/node_modules/protodef/src/compiler.js:96:20)
    at Serializer.createPacketBuffer (/home/amelia/mcbot/node_modules/protodef/src/serializer.js:12:23)
    at Serializer._transform (/home/amelia/mcbot/node_modules/protodef/src/serializer.js:18:18) {
  field: 'play.toServer'
}

What did you try yet?

Looking at the error messages, it does not seem to be linked to anything in my code. However, I tried anyway, thinking this may have happened too deep in the code for it to print out.
The following is what I have tried, all of which have failed to solve the problem:

  • I put an empty array [] instead of the function, so that it would be writeBook(book.slot, []).
  • I put an array that was not empty but would fit on a normal minecraft book (["abcdefg"])
  • I didn't use book.slot but instead used some other test slot that I knew would be empty during my testing. This produced a more sane error that did go into the catch statement, but it did tell me that I was indeed correct with my usage of book.slot

It is also worth mentioning that it is certain book is an actual item in the inventory, and the pages array is indeed an array of strings.

Expected behavior

I expected for the book to be written and for the code to continue as usual, or for it to atleast enter the catch portion like a normal error.

@AmeliaYeah AmeliaYeah added possible bug Stage1 just created by someone new to the project, we don't know yet if it deserves an implementation / a f labels Sep 27, 2023
@AmeliaYeah
Copy link
Author

So I have downgraded to version 1.16 and it appears to work, I suppose this is just an issue with 1.19.3 not being supported yet.

@HellishBro
Copy link

dont leave us hanging

@szdytom
Copy link
Contributor

szdytom commented Nov 1, 2023

can confirm in 1.20.1

@andreasdc
Copy link

I have this error on 1.20.2

@mindfilleter
Copy link

Tested in 1.20 as well using the provided book.js example verbatim. The bot disconnects and I get the below pasted error in the console.

I'm trying to fill chiseled bookcase library with all of the books from Skyrim, but unfortunately my project is blocked by this. I hope it can be prioritized by the maintainers.

(node:24756) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
logged in
TypeError: Serialization error for play.toServer : SizeOf error for undefined : Cannot read properties of undefined (reading 'length')
    at eval (eval at compile (/home/user/src/web/mcbots/node_modules/protodef/src/compiler.js:258:12), <anonymous>:756:39)
    at Object.packet_edit_book (eval at compile (/home/user/src/web/mcbots/node_modules/protodef/src/compiler.js:258:12), <anonymous>:761:9)
    at eval (eval at compile (/home/user/src/web/mcbots/node_modules/protodef/src/compiler.js:258:12), <anonymous>:1305:58)
    at packet (eval at compile (/home/user/src/web/mcbots/node_modules/protodef/src/compiler.js:258:12), <anonymous>:1345:9)
    at CompiledProtodef.sizeOf (/home/user/src/web/mcbots/node_modules/protodef/src/compiler.js:89:14)
    at e.message (/home/user/src/web/mcbots/node_modules/protodef/src/compiler.js:96:40)
    at tryCatch (/home/user/src/web/mcbots/node_modules/protodef/src/utils.js:50:16)
    at CompiledProtodef.createPacketBuffer (/home/user/src/web/mcbots/node_modules/protodef/src/compiler.js:96:20)
    at Serializer.createPacketBuffer (/home/user/src/web/mcbots/node_modules/protodef/src/serializer.js:12:23)
    at Serializer._transform (/home/user/src/web/mcbots/node_modules/protodef/src/serializer.js:18:18) {
  field: 'play.toServer'
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
possible bug Stage1 just created by someone new to the project, we don't know yet if it deserves an implementation / a f
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants