Skip to content

Buffer.writeUInt64BE should return offset plus bytes written #17694

@cody-greene

Description

@cody-greene

What version of Bun is running?

1.2.3+8c4d3ff80

What platform is your computer?

Linux 6.13.3-arch1-1 x86_64 unknown

What steps can reproduce the bug?

const buf = Buffer.alloc(8)
buf.writeBigUInt64BE(7n) // returns 0

writeBigUInt64BE seems to return the offset without the number of bytes written. This diverges from nodejs.

What is the expected behavior?

https://nodejs.org/api/buffer.html#bufwritebiguint64bevalue-offset

buf.writeBigUInt64BE(value[, offset])

  • value Number to be written to buf.
  • offset Number of bytes to skip before starting to write. Must satisfy: 0 <= offset <= buf.length - 8. Default: 0.
  • Returns: offset plus the number of bytes written.

Writes value to buf at the specified offset as big-endian.

This method should return the offset (default=0) + 8 since it always writes 8 bytes.

What do you see instead?

No response

Additional information

I suspect other buffer write methods may have the same problem (with zero evidence).

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingnode.jsCompatibility with Node.js APIsregression

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions