Skip to content

fs.close twice different behavior on Windows 10 #3718

Description

@thisconnect

The following test case opens a file, and closes it twice expecting to get an Error.

var assert = require('assert');
var fs = require('fs');

// 'w+' - Open file for reading and writing.
// The file is created (if it does not exist)
// or truncated (if it exists).

fs.open(__dirname + '/test-to-open-a-file.txt', 'w+', function(err1, fd){

    console.log('open', fd);
    fs.close(fd, function(err2){

        console.log('close - should have no error', fd);
        assert.ifError(err2);

        fs.close(fd, function(err3){
            console.log('close2 - expect an error', fd);
            console.error(err3);
        });
    });
});

On Linux/Mac the second close callback err3 has the following Error: { [Error: EBADF: bad file descriptor, close] errno: -9, code: 'EBADF', syscall: 'close' }

On Windows 10 the second callback err3 has null

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    confirmed-bugIssues and PRs for confirmed bugs.fsIssues and PRs related to file-system APIs and the fs module.windowsIssues and PRs related to the Windows platform.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions