bchelli/node-smb2

TypeError: Cannot read property 'FileId' of undefined when calling close()

DaSpawn opened this issue · 3 comments

I am opening the connection to the server, checking for a file (smb2Client.exists), reading another file from the share (smb2Client.readFile), then doing some work that can take 30 seconds or more, then writing the file back to the share (smb2Client.createWriteStream) piped from a readStream

I previously had this working without issue until I ran into the timeouts. I set the autoCloseTimeout to 0 and tried to use the smb2Client.close in the writeStream.on('finish') but it throws an error after writing the file

TypeError: Cannot read property 'FileId' of undefined (node_modules/@marsaud/smb2/lib/messages/close.js:14:24)

the file is written properly but how can I solve the error thrown and close the connection properly?

Hi @DaSpawn

It look like you are using @marsaud/smb2 instead of smb2

TypeError: Cannot read property 'FileId' of undefined (node_modules/@marsaud/smb2/lib/messages/close.js:14:24)

Can you try

  1. to install smb2:
npm install smb2
  1. Replace the requirement in your js file:
var SMB2 = require('smb2');

And try again to reproduce the issue.

Thanks,

Forgot about using that. I needed createWriteStream as I thought the writefile function was truncating my data. I finally solved that as the end() on my temp file was still busy writing when I read for writefile data

do you plan on adding the createWriteStream function (it works beautifully and I have plans on much larger files that can not be read into memory)?

Thank you

This is definitely something on my TODO list.
Thanks