Skip to content

Two types of filehandle.read return different values #41558

@nujarum

Description

@nujarum

Version

v14.18.3 / v16.13.2

Platform

Microsoft Windows NT 10.0.19044.0 x64

Subsystem

fs/promises

What steps will reproduce the bug?

import { open } from 'fs/promises';

const path = '/path/to/file';
const fh = await open(path, 'w+'); // reading & writing

const input = new Uint8Array([0, 1, 2, 3]);
await fh.writeFile(input);

const length = input.byteLength;
const buffer = new Uint8Array(length);
const offset = 0;
const position = 0;

const result1 = await fh.read(buffer, offset, length, position);     // 4 parameters
const result2 = await fh.read({ buffer, offset, length, position }); // 1 object parameter

console.log('result1:', result1);
console.log('result2:', result2);

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

No response

What is the expected behavior?

I think the expected behavior is that these two return values are the same.

What do you see instead?

result1: { bytesRead: 4, buffer: Uint8Array(4) [ 0, 1, 2, 3 ] }
result2: { bytesRead: 0, buffer: Uint8Array(4) [ 0, 1, 2, 3 ] }

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    fsIssues and PRs related to the fs subsystem / file system.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions