Skip to content
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

Using createWriteStream does not work as intended #900

Open
yory100 opened this issue Mar 28, 2023 · 3 comments
Open

Using createWriteStream does not work as intended #900

yory100 opened this issue Mar 28, 2023 · 3 comments

Comments

@yory100
Copy link

yory100 commented Mar 28, 2023

I am downloading a file from google drive, which works perfectly with node fs module with this code

const drive = google.drive({ version: "v3", auth });
const dest = fs.createWriteStream("./downloaded.zip");

drive.files.get(
    { fileId: "google-file-id", alt: "media" },
    { responseType: "stream" },
    (err, res) => {
        res?.data.pipe(dest);
    }
);

but when using memfs I am receiving this error

"Error: ENOENT: no such file or directory, open '/home/yory/casino-odr-v2/services/casino-odr-v2/downloaded.zip'\n at createError (/home/yory/casino-odr-v2/node_modules/.pnpm/memfs@3.4.13/node_modules/memfs/lib/volume.js:128:17)\n at Volume.openFile (/home/yory/casino-odr-v2/node_modules/.pnpm/memfs@3.4.13/node_modules/memfs/lib/volume.js:850:23)\n at Volume.openBase (/home/yory/casino-odr-v2/node_modules/.pnpm/memfs@3.4.13/node_modules/memfs/lib/volume.js:861:25)\n at Immediate. (/home/yory/casino-odr-v2/node_modules/.pnpm/memfs@3.4.13/node_modules/memfs/lib/volume.js:698:33)\n at processImmediate (node:internal/timers:471:21)\n at process.callbackTrampoline (node:internal/async_hooks:130:17)"

@System233
Copy link

Same problem:

import { fs } from "memfs";

const ss=fs.createWriteStream('test');// BOOM!
ss.write('fawfawf');
ss.end()

ERROR:

.\node_modules\memfs\lib\volume.js:128
    var error = new Constructor(formatError(errorCode, func, path, path2));
                ^
Error: ENOENT: no such file or directory, open '/.../test'
    at createError (.\node_modules\memfs\lib\volume.js:128:17)
    at Volume.openFile (.\node_modules\memfs\lib\volume.js:853:23)
    at Volume.openBase (.\node_modules\memfs\lib\volume.js:864:25)
    at Immediate.<anonymous> (.\node_modules\memfs\lib\volume.js:698:33)
    at processImmediate (node:internal/timers:476:21) {
  code: 'ENOENT',
  path: '/.../test'}

@cerpins
Copy link

cerpins commented Jun 5, 2023

also experiencing this issue with .end() and .close(). piping to the write stream seems to work fine though

@G-Rath
Copy link
Collaborator

G-Rath commented Jun 5, 2023

PRs are welcome - alternatively if someone puts together a small reproduction (ideally that does not involve third-party services), I can try to dig into this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants