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
First of all, fantastic library!!!. I've been putting off my CI upgrades to node 10.5+ because of mock-fs not supporting them yet. Seeing as that great work is merged, I attempted to upgrade, but hit the issue that I've honed down to this reproduction:
// FILE: temp-test.js// Reproduction.const{ readFile }=require("fs");constmock=require("mock-fs");const{ promisify }=require("util");// Convert to promises for readability. Works the same with callbacks.constreadFileP=promisify(readFile);const{DO_REAL_READFILE}=process.env;(async()=>{if(DO_REAL_READFILE==="true"){// TODO HERE: Merely adding a **real** `readFile` of the any file before// errors the latter one. Comment this out and test passes.// Uncomment and test hangs.constbuf1=awaitreadFileP("package.json");console.log("TODO HERE 001",{data: buf1.toString()});}// Also, if no `mock()`, the two real readFile calls also succeed.mock({"package.json": "BAD_NOT_JSON",});constbuf2=awaitreadFileP("package.json");console.log("TODO HERE 002",{data: buf2.toString()});})();
The issue is that doing a mix of a realreadFile and then a mock() call and then another readFile (the calls don't have to match the same file) results in the mocked, second readFile call hanging the process.
And more specifically, if that file exists as a mock for "package.json", the process hangs. If instead, mock() is used, there is an ENOENT thrown as expected because the mocked file isn't found.
Usage:
$ nvm use 8
Now using node v8.11.3 (npm v5.6.0)
$ node --version
v8.11.3
$ node temp-test.js
# doesn't hang
$ DO_REAL_READFILE=true node temp-test.js
# doesn't hang
$ nvm use 10
Now using node v10.13.0 (npm v6.4.1)
$ node --version
v10.13.0
$ node temp-test.js
# doesn't hang
$ DO_REAL_READFILE=true node temp-test.js
# HERE -- THIS HANGS THE PROCESS after 001 log before 002 log.
I'm not sure exactly what's up internally, but hopefully this is pretty straightforward reproduction. Let me know if I can provide any more info.
Apologies if there is something obvious / configuration-wise / etc. that I'm missing as to why this isn't working for me...
Thanks!
The text was updated successfully, but these errors were encountered:
@tschaub -- Works like a charm! My (very heavily leveraging mock-fs) tests now pass in 8, 10, 11 for Travis and Appveyor: FormidableLabs/inspectpack#113
First of all, fantastic library!!!. I've been putting off my CI upgrades to node 10.5+ because of mock-fs not supporting them yet. Seeing as that great work is merged, I attempted to upgrade, but hit the issue that I've honed down to this reproduction:
The issue is that doing a mix of a real
readFile
and then amock()
call and then anotherreadFile
(the calls don't have to match the same file) results in the mocked, secondreadFile
call hanging the process.And more specifically, if that file exists as a mock for
"package.json"
, the process hangs. If instead,mock()
is used, there is anENOENT
thrown as expected because the mocked file isn't found.Usage:
I'm not sure exactly what's up internally, but hopefully this is pretty straightforward reproduction. Let me know if I can provide any more info.
Apologies if there is something obvious / configuration-wise / etc. that I'm missing as to why this isn't working for me...
Thanks!
The text was updated successfully, but these errors were encountered: