-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error STATUS_FILE_CLOSED after pipe stream created with createReadStream #82
Comments
Also affecting me. Although it looks like the file is being read thoroughly |
The same is happening to me, and as @brunocw-cit said, the file is being read. Any help? |
hey @mbrowng i know its not ideal (if you're reading a large file) but what worked for me was using 'await smb2client.readFile' instead of 'createReadStream' to read my file all at once instead of streaming it. |
So!... I have found out how to hide this error while (hopefully) not destroying anything else! const stream = await smb2Client.createReadStream(path);
res.contentType(extname(path));
stream.pipe(res).once('drain', () => stream._destroy = () => { }); I know this looks scary, but the stream gets closed twice. Replacing |
Do we have an update on this? Seems to be happening when I upgrade to node ~>=16 |
@Akxe i tried your fix, but i'm still seeing the error. the stream does seem to work fine despite this. If anyone else sees this or has a solution for streaming files over SMB in node in 2023 I'd be much obliged! my demo code which returns the file's contents over simple http server import SMB2 from '@marsaud/smb2'
import http from 'node:http'
let smb2Client = new SMB2({
share: '\\\\localhost\\public',
domain: 'somedomain',
username: 'myuser',
password: 'mypass'
})
let server = http.createServer(async (req, res) => {
console.log(`Request for ${req.method} - ${req.url}`)
let filePath = 'folder/test_file'
let stream = await smb2Client.createReadStream(filePath)
res.write('some value from SMB:')
stream.pipe(res).once('drain', () => stream._destroy = () => { console.log('closing a second time?') })
})
server.listen(3000, () => console.log('listening on 3000')) |
It worked for me, By using SmbClient.Open to get the fd descriptor. Then using the file descriptor for opening the file for stream and chosing option "autoClose" Then once the file is read, closing the fd by yourself |
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 :
----ERROR Message
Can you help me on this issue ?
Best regards
The text was updated successfully, but these errors were encountered: