Skip to content

fs.promises FileHandle.read() not working with object argument as stated in docs. #34176

@branisha

Description

@branisha
  • Version: v14.4.0
  • Platform: Linux arch 5.7.2-arch1-1
  • Subsystem: fs.promises FileHandle

What steps will reproduce the bug?

Using FileHandle.read() with object argument.
This example throws TypeError:

const fs_p = require('fs').promises;
fs_p.open('exampleFile.txt', 'r')
    .then((fileHandler) => {
        const header_buffer = Buffer.alloc(10);
        fileHandler.read({ buffer: header_buffer, offset: 12 })
            .then(({ bytesRead, buffer }) => {
                console.log("Reading")
            }).catch((err) => {
                throw err;
            });
    }).catch((err) => {
        throw err;
    });

How often does it reproduce? Is there a required condition?

Everytime you use object as argument.

What is the expected behavior?

Method should accept object as parameter, as stated in docs here.

What do you see instead?

TypeError [ERR_INVALID_ARG_TYPE]: The "buffer" argument must be an instance of Buffer, TypedArray, or DataView. Received an instance of Object

Additional information

This bug dosen't seem too complicated, maybe I could fix it.

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