You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a strange problem with fs-extra, archiver and mock-fs in combination. I am running on node 16.13.2 but it seems to be broken on all nodejs 16 and 17 versions.
Here is the code example
constfs=require("fs-extra");const{ promisify }=require("util");const{ pipeline }=require("stream/promises");const{ setImmediate }=require("timers/promises");constpEvent=require("p-event");constarchiver=require("archiver");constStreamZip=require("node-stream-zip");constmockfs=require("mock-fs");asyncfunctionunzip(filePath,targetDir){constzip=newStreamZip({file: filePath,storeEntries: true,});constextract=promisify(zip.extract).bind(zip);awaitpEvent(zip,"ready");constcount=awaitextract(null,targetDir);zip.close();returncount;}asyncfunctionmain(){mockfs({"someFile.txt": "Content 1",});awaitsetImmediate();// without setImmediate no problemfileReadStream=fs.createReadStream("someFile.txt",{encoding: "utf-8"});constoutput=fs.createWriteStream("foo.zip");constarchive=archiver("zip",{zlib: {level: 0},});constpipelinePromise=pipeline(archive,output);constentryEvent=pEvent(archive,"entry");archive.append(fileReadStream,{name: "someFile.txt"});awaitentryEvent;awaitarchive.finalize();awaitpipelinePromise;awaitunzip("foo.zip",".");};main().catch(e=>console.log(e));
With this code sample I get the following error: Invalid local header.
If nodejs v14 has no issue, it's related to the readstream timing breaking change in nodejs v16. We don't fully understand some side effect. I am particularly puzzled by the effect of await setImmediate();. #338
Hey there,
I have a strange problem with fs-extra, archiver and mock-fs in combination. I am running on node 16.13.2 but it seems to be broken on all nodejs 16 and 17 versions.
Here is the code example
With this code sample I get the following error: Invalid local header.
The error does NOT occur:
Does anyone know what is going on here?
package.json
The text was updated successfully, but these errors were encountered: