Skip to content

Error STATUS_FILE_CLOSED after pipe stream created with createReadStream #82

@julien13630

Description

@julien13630

Hi,

I have an error when i'm reading list of file using readstream.
I have a loop on all file of a dir.
For each file I create a read stream that I pipe to a csv parser streamwritter (https://www.npmjs.com/package/csv-parser).
File is read well but when at the end of loop an error STATUS_FILE_CLOSED occures :

[...]

for (let file of files) {
            try {
                if(file.isDirectory())
                {
                    continue;
                }
                var rs = await smb2Client.createReadStream('dummy\\path\\test\\' + file.name,);
                rows.push(...await manageCsvFile(rs));
            } catch (e) {
                console.log('error on file' + file.name, e)
            }
}
[...]

--------

async function manageCsvFile(rs) {
    let rows = [];
    var fd = rs.pipe(csv({
        separator: ';'
    }));
    var end = new Promise(function(resolve, reject) {
        fd.on('data', (row) => {
            rows.push(row);
        })
        fd.on('end', () => {
            console.log('CSV file successfully processed');
        })
        fd.on('close', () => {
            console.log('Stream has been destroyed and file has been closed');
            resolve();
        });
    });
    await end;
    return rows;
}

----ERROR Message

"errorType": "Error",
  "errorMessage": "STATUS_FILE_CLOSED (0xC0000128) : An I/O request other than close and several other special case operations was attempted using a file object that had already been closed.",
  "trace": [
    "Error: STATUS_FILE_CLOSED (0xC0000128) : An I/O request other than close and several other special case operations was attempted using a file object that had already been closed.",
    "    at SMB2Forge.request (/var/task/node_modules/@marsaud/smb2/lib/tools/smb2-forge.js:22:15)",
    "    at Readable.stream._destroy (/var/task/node_modules/@marsaud/smb2/lib/api/createReadStream.js:42:9)",
    "    at Readable.destroy (internal/streams/destroy.js:39:8)",
    "    at endReadableNT (internal/streams/readable.js:1350:16)",
    "    at processTicksAndRejections (internal/process/task_queues.js:82:21)"
  ]

Can you help me on this issue ?
Best regards

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