Skip to content

buf.readUInt32BE() reports a "write" error on out-of-bounds, instead of a "read" error #29097

@sam-github

Description

@sam-github
  • Version: 12.x
  • Platform: any?
  • Subsystem: Buffer

See below. It seems like the error should mention reading, not writing?

It could be that internally, a write is done, or even that this is no big deal and should be closed with "as expected/good enough" -- though in a large system it might be less obvious what is wrong than in the repl snippet below.

> Buffer.from([2,3,4]).readUInt32BE()
Thrown:
RangeError [ERR_BUFFER_OUT_OF_BOUNDS]: Attempt to write outside buffer bounds
    at boundsError (internal/buffer.js:70:11)
    at Buffer.readUInt32BE (internal/buffer.js:295:5)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions