#Cannot read properties of null (reading 'byteLength')

21 messages · Page 1 of 1 (latest)

stark fiber
#

I keep getting this error in my script but I can't figure out the cause of it.

TypeError: Cannot read properties of null (reading 'byteLength')
    at Object.pull (C:\Users\*\Documents\Bot\node_modules\undici\lib\web\fetch\body.js:66:20)
    at invokePromiseCallback (node:internal/webstreams/util:172:10)
    at Object.<anonymous> (node:internal/webstreams/util:177:23)
    at readableByteStreamControllerCallPullIfNeeded (node:internal/webstreams/readablestream:3145:24)
    at readableByteStreamControllerPullSteps (node:internal/webstreams/readablestream:3254:3)
    at [kPull] (node:internal/webstreams/readablestream:1201:5)
    at readableStreamDefaultReaderRead (node:internal/webstreams/readablestream:2269:39)
    at nextSteps (node:internal/webstreams/readablestream:493:7)
    at async writeIterable (C:\Users\*\Documents\Bot\node_modules\undici\lib\dispatcher\client-h1.js:1439:22)

Short code snippet:

if (interaction.commandName === "cardtest") {
    const canvas = createCanvas(700, 250);
    const context = canvas.getContext('2d');

    const backgroundPath = path.join(__dirname, "assets", "contribution-card-background.png")
    const background = await readFile(backgroundPath);
    const backgroundImage = new Image();
    backgroundImage.src = background;
    context.drawImage(backgroundImage, 0, 0, canvas.width, canvas.height);

    const attachment = new AttachmentBuilder(canvas.toBuffer('image/png'), { name: 'profile-image.png' });
    console.log(attachment)

    interaction.reply({ files: [attachment] });
}
rough spireBOT
stark fiber
hasty shoal
hasty shoal
#

Can you do, npm ls @discordjs/rest and show me the output?

hasty shoal
#

Weird, this was fixed. I'm not sure if the fix was backported tho

stark fiber
#

i've been stuck at this problem for a few hours now, I might just scrap the entire thing for the time being

hasty shoal
stark fiber
#

that sucks

#

not really sure where to go from there

hasty shoal
stark fiber
hasty shoal
#

Then that's likely the issue, the version affected with the bug is not used by d.js, so you installing the latest version could be the issue here

stark fiber
#

let me try and uninstall

#

the built attachment exists I think, but the image is never sent via reply

#

the error doesnt show up anymore either

#

theres nothing wrong with this is there

const attachment = new AttachmentBuilder(canvas.toBuffer('image/png'), { name: 'profile-image.png' });
return interaction.reply({ files: [attachment] })
stark fiber
#

so things work now because I also had noblox.js installed

#

which was interferring with the discord.js' undici