os-js/OS.js

Crashing the osjs when uploading a file in osjs mountpoint

maryam4s26 opened this issue · 3 comments

hi.
when I upgrade node version to 16 and upload the file in osjs mountpoint, osjs crashes. How can I fix this?

@andersevenrud
@ajmeese7

Screenshot from 2023-12-24 18-07-19

I think we should handle the error in this way so that it does not crash:
https://github.com/os-js/osjs-server/blob/master/src/utils/vfs.js#L71

Change from code 1 to 2:

return isStream
    ? req.files.upload
    : fs.createReadStream(req.files.upload.path);
return isStream
    ? req.files.upload
    : fs.createReadStream(req.files.upload.path)
        .on('error', function(err) {})

Thanks for reporting! 👍

I'm away because of the holidays, so I cannot look into this myself at the moment.

Feel free to submit a PR to the osjs-server repository if you have a working solution. This is probably also something that could use a unit test to verify the problem and the solution.

Just published @osjs/server@3.4.0 that includes the fix.