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
Different behavior with yauzl #352
Comments
The scripts have a
|
My bad, I missed the mock argument. I can reproduce the issue on both node v14 and v16. |
I don't quite understand this Nodejs (or JavaScript) feature, the promise that handles events "error", "entry" and "end". I thought only the reject and resolve calls interact with the promise itself? |
The variable const globalZipfile = await new Promise((resolve, reject) => {
yauzl.open("baz.zip", (err, callbackZipfile) => {
if (err) reject(err);
resolve(callbackZipfile);
});
}); |
Here is another test case using import mock from "mock-fs";
import yauzl from "yauzl";
if (process.argv.includes("mock")) {
mock({ "baz.zip": mock.load("baz.zip") });
}
yauzl.open("baz.zip", (err, zipfile) => {
if (err) throw err;
setImmediate(() => {
zipfile.on("error", (err) => console.log("error", err));
zipfile.on("entry", (entry) => console.log("entry", entry.fileName));
zipfile.on("end", () => console.log("end"));
});
}); |
Oh, I see. I got confused. It's the resolved value in play. |
Feels like another timing issue because of our readStream patch. |
The yauzl library has a different behavior with mock-fs.
The above code prints :
entry foo.txt
andend
end
I think the problem is that mock-fs does not call IO and returns the result directly (Event Loop). Because without the promise, the behavior is the same.
To reproduce the problem:
npm install
node fail.js
node fail.js mock
The text was updated successfully, but these errors were encountered: