Skip to content

fs.close twice different behavior on Windows 10 #3718

Closed
@thisconnect

Description

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

Metadata

Assignees

No one assigned

    Labels

    confirmed-bugIssues with confirmed bugs.fsIssues and PRs related to the fs subsystem / file system.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