Open
Description
What version of Bun is running?
1.1.20+ae1948925
What platform is your computer?
Linux 6.9.10-arch1-1 x86_64 unknown
What steps can reproduce the bug?
const server = await Bun.udpSocket({
socket: {
data(socket, buf, port, addr) {
console.log(`message from ${addr}:${port}:`)
console.log(buf, buf.length);
}
}
})
const buf = new Uint32Array(64);
buf.fill(100);
const client = await Bun.udpSocket({
connect: {
port: server.port,
hostname: 'localhost'
}
});
client.send(buf);
What is the expected behavior?
message from 127.0.0.1:60292:
Buffer(64) [ 100, 0, 0, 0, 100, 0, 0, 0, 100, 0, 0, 0, 100, 0, 0, 0, 100, 0, 0, 0, 100, 0, 0, 0, 100, 0, 0, 0, 100, 0, 0, 0 ] 64
What do you see instead?
message from 127.0.0.1:60292:
Buffer(8) [ 100, 0, 0, 0, 100, 0, 0, 0 ] 8
Additional information
It appears to be sending the amount of bytes based on the length of the buffer, instead of the proper stride*length. It can be worked around if you wrap the data like so new Uint8Array(buf.buffer)
and then send it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment