Skip to content

Some possible bugs concerning fs.appendFile() and fs.writeFile() #11595

@vsemozhetbyt

Description

@vsemozhetbyt
  • Version: 7.6.0
  • Platform: Windows 7 x64
  • Subsystem: fs, test

1. fs.appendFile() and fs.writeFile() can be called without mandatory data parameter, while not throwing any error messages. Thus, the only second parameter serves as data and callback (mandatory as well) parameters at the same time.

const fs = require('fs');

const cb = (err) => { if(err) console.error(err); }

fs.appendFile('append-file.txt', cb);
fs.writeFile('write-file.txt', cb);

This code runs without any errors and produces 2 files with the same content:

> cat append-file.txt
(err) => { if(err) console.error(err); }
> cat write-file.txt
(err) => { if(err) console.error(err); }

It seems this is hardly an expected behavior.

2. test/parallel/test-fs-null-bytes.js tests these functions with wrong parameters scheme, i.e. without mandatory data parameter. This may be not very important for the test aim, but it makes it somehow compromised.

Metadata

Metadata

Assignees

No one assigned

    Labels

    confirmed-bugIssues with confirmed bugs.fsIssues and PRs related to the fs subsystem / file system.good first issueIssues that are suitable for first-time contributors.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions