Skip to content

Conversation

@sanfilippopablo
Copy link
Contributor

When the underlying file changed in the FS, stat can give wrong information because if it exists in the index cache it reports the data from when that entry was loaded. This is a problem in itself, but it also causes issues when re-reading a file that was modified outside zenfs, because readFile uses stat to determine the type of the buffer and when there is a mismatch it throws an error.

This makes stat always report the real data from the underlying FS.

@james-pre
Copy link
Member

james-pre commented Aug 29, 2025

Hey @sanfilippopablo, thanks for opening a PR!

It looks like these changes would prevent changes to metadata (e.g. via chmod). While I'd like to test to see if that is the case, there are a quite a few problems with WebAccess and the Async mixin it uses. Please be patient while I work through those other problems.

This problem is definitly valid though, and trying to allow changes to metadata while staying in sync with the underlying API will be a challenge.

@james-pre
Copy link
Member

james-pre commented Aug 31, 2025

Hey @sanfilippopablo, I've gone ahead and fixed WebAccess. It now tests in CI, so you should be able to see the test results in the PR. Please rebase the PR branch when you get a chance.

Once all tests pass after the rebase, I'll review the PR. Thanks again for opening it!

@sanfilippopablo
Copy link
Contributor Author

@james-pre Ok so I rebased and tests don't pass. That said, I looked at the output and I see this:

  Error: ENOENT: No such file or directory, undefined '/x.txt'
      at StoreFS.findInodeSync (file:///Users/pablo/prewitt-ridge/zenfs-dom/node_modules/@zenfs/core/dist/backends/store/fs.js:839:19)
      at StoreFS.statSync (file:///Users/pablo/prewitt-ridge/zenfs-dom/node_modules/@zenfs/core/dist/backends/store/fs.js:395:25)
      at Module.statSync (file:///Users/pablo/prewitt-ridge/zenfs-dom/node_modules/@zenfs/core/dist/vfs/sync.js:130:20)
      at TestContext.<anonymous> (/Users/pablo/prewitt-ridge/zenfs-dom/node_modules/@zenfs/core/tests/fs/times.test.ts:70:21)
      at Test.runInAsyncScope (node:async_hooks:214:14)
      at Test.run (node:internal/test_runner/test:1062:25)
      at Suite.processPendingSubtests (node:internal/test_runner/test:752:18)
      at Test.postRun (node:internal/test_runner/test:1191:19)
      at Test.run (node:internal/test_runner/test:1119:12)
      at async Promise.all (index 0) {
    errno: 2,
    code: 'ENOENT',
    path: '/x.txt',
    dest: undefined,
    syscall: undefined
  }

But I'm not sure where exactly is that failing. I can look more into the test setup later

@james-pre
Copy link
Member

james-pre commented Sep 1, 2025

Hey @sanfilippopablo,

As I suspected, this PR prevents modification to metadata— including the mode. Consequently, different file types (like symlinks) and permissions are broken.

For example, notice how the times are not updated in this test.

Supporting modifications to metadata while also combating de-sync with the underlying API is tricky, so good luck.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants