Closed hawav closed 4 months ago
Okay, I've successfully reproduced the issue. I can confirm AsyncFS.crossCopy
is not even called, so I believe that is the issue.
Edit: FetchFS
does not mixin Async
so it will not have caching, which means that it won't even have a sync cache fs.
@hawav This should be fixed in v0.12.0. Can you please test it with your use case, to make sure? Thanks!
- JP
@james-pre Unfortunately, the issue still persists in v0.12.0. I've verified that I'm using the correct version, and after reproducing the issue again, I can confirm that the readFileSync
function is not working as expected.
Could you please investigate further to identify the root cause and provide a fix? Thanks for your help and attention to this issue.
@hawav Could you provide a complete stack trace of the error message? (Please copy and paste into a code block).
@james-pre Here is the complete stack trace of the error message:
Uncaught Error: ENOENT: No such file or directory, '/test.txt'
ErrnoError error.js:261
With error.js:249
_openSync sync.js:113
_readFileSync sync.js:165
readFileSync sync.js:184
EditorWindow page.tsx:27
... (no more zenfs related stack)
I hope you don't mind, I truncated the stack trace you provided to the part relevant to ZenFS.
In any case, could you please make this change to the dist/emulation/sync.js file:
@@ -100,6 +100,7 @@ function _openSync(_path, _flag, _mode, resolveSymlinks = true) {
stats = wrap('statSync', resolveSymlinks, path, cred);
}
catch (e) {
+ debugger;
// File does not exist.
switch (pathNotExistsAction(flag)) {
case ActionType.CREATE:
Then comment with e
(the error being caught)?
Of course, here is the content of e
:
Error: ENOENT: No such file or directory, '/test.txt'
ErrnoError error.js:261
With error.js:249
_findINodeSync fs.js:454
findINodeSync fs.js:474
statSync fs.js:204
wrap sync.js:15
_openSync sync.js:100
_readFileSync sync.js:165
readFileSync sync.js:184
@hawav 0.12.1 made some changes. I doubt it fixed the issue, but could you check anyway? Also, could you provide an updated stack trace? You won't need to make any changes or open the debugger since _open
and _openSync
correctly throw errors now.
After upgrading to version 0.12.1 of @zenfs/core
, I encountered an error with the message EINVAL: Index version mismatch
. This error suggests that there might be a mismatch in the index version between the older and newer versions of the library.
To resolve this issue, I regenerated the index.json
file using the latest version of @zenfs/core
with the following command:
npx -p @zenfs/core@0.12.1 make-index . -o index.json
After executing this command, the error was resolved, and I was able to successfully retrieve the content of the file, which reads "Hello ZenFS!".
Since I've confirmed that the issue has been resolved, I'm going to close this issue.
If this issue persists for other users, it might be worth investigating the version compatibility between the older and newer versions of the index.json
format in @zenfs/core
.
Thank you for your attention to this matter!
@hawav In hindsight, I believe your index.json may have been invalid for 0.11.*. This would explain why the issue was fixed on my side but not on yours.
0.12.0 did change the index.json format to use versioning, and to store the entries in a different way which actually keeps track of stats.
@zenfs/core
versions: 0.11.2, 0.12.0Expected Behavior:
The
readFileSync
function should be able to fetch the content oftest.txt
from the remote server, just like thereadFile
function does.Actual Behavior:
The
readFileSync
function throws anENOENT
error, indicating that it cannot find the file, which is not true.Steps to Reproduce:
test.txt
in the directory with the content "Hello ZenFS!"make-index
script from ZenFS.serve
on port 8080 with CORS enabled.Fetch
Backend, pointing to the local server.readFile
function to successfully fetch test.txt from the remote server.