Skip to content
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

[Bug]: Error: ENOENT: no such file or directory when deleting page directory #9837

Open
1 task done
Tobbe opened this issue Jan 16, 2024 · 2 comments
Open
1 task done

Comments

@Tobbe
Copy link
Member

Tobbe commented Jan 16, 2024

What's not working?

I get the following error when I manually delete a page directory

gen | node:fs:453
gen |     return binding.readFileUtf8(path, stringToFlags(options.flag));
gen |                    ^
gen | 
gen | Error: ENOENT: no such file or directory, open '/Users/tobbe/tmp/rw-test-project-ga-sentry/web/src/pages/DummyPage/DummyPage.tsx'
gen |     at Object.readFileSync (node:fs:453:20)
gen |     at fileToAst (/Users/tobbe/tmp/rw-test-project-ga-sentry/node_modules/@redwoodjs/internal/dist/ast.js:22:28)
gen |     at isPageFile (/Users/tobbe/tmp/rw-test-project-ga-sentry/node_modules/@redwoodjs/internal/dist/files.js:169:34)
gen |     at FSWatcher.<anonymous> (/Users/tobbe/tmp/rw-test-project-ga-sentry/node_modules/@redwoodjs/internal/dist/generate/watch.js:92:99)
gen |     at FSWatcher.emit (node:events:514:28)
gen |     at FSWatcher.emitWithAll (/Users/tobbe/tmp/rw-test-project-ga-sentry/node_modules/chokidar/index.js:541:32)
gen |     at FSWatcher._emit (/Users/tobbe/tmp/rw-test-project-ga-sentry/node_modules/chokidar/index.js:632:8)
gen |     at FSWatcher._remove (/Users/tobbe/tmp/rw-test-project-ga-sentry/node_modules/chokidar/index.js:895:50)
gen |     at FsEventsHandler.handleEvent (/Users/tobbe/tmp/rw-test-project-ga-sentry/node_modules/chokidar/lib/fsevents-handler.js:267:16)
gen |     at FsEventsHandler.checkExists (/Users/tobbe/tmp/rw-test-project-ga-sentry/node_modules/chokidar/lib/fsevents-handler.js:255:12) {
gen |   errno: -2,
gen |   code: 'ENOENT',
gen |   syscall: 'open',
gen |   path: '/Users/tobbe/tmp/rw-test-project-ga-sentry/web/src/pages/DummyPage/DummyPage.tsx'
gen | }
gen | 
gen | Node.js v20.10.0
gen | yarn rw-gen-watch exited with code 1

How do we reproduce the bug?

  1. Create a new empty RW app
  2. yarn rw dev in terminal 1
  3. yarn rw g page Dummy in terminal 2
  4. rm -fr web/src/pages/DummyPage also in terminal 2

You'll now see the error in terminal 1

What's your environment? (If it applies)

❯ yarn rw info        

  System:
    OS: macOS 14.1.1
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.10.0 - /private/var/folders/7j/9p56mwmj6jsfdr2h5_884j9w0000gn/T/xfs-e0cad5fb/node
    Yarn: 4.0.2 - /private/var/folders/7j/9p56mwmj6jsfdr2h5_884j9w0000gn/T/xfs-e0cad5fb/yarn
  Databases:
    SQLite: 3.39.5 - /usr/bin/sqlite3
  Browsers:
    Safari: 17.1
  npmPackages:
    @redwoodjs/core: 7.0.0-canary.840 => 7.0.0-canary.840+d7d703d88

Are you interested in working on this?

  • I'm interested in working on this
@Tobbe Tobbe added the bug/needs-info More information is needed for reproduction label Jan 16, 2024
@Tobbe
Copy link
Member Author

Tobbe commented Jan 16, 2024

The problem is that we have a file watcher running that detects when files are deleted to update our generated types. It runs functions like isPageFile, isCell etc. They in turn use fileToAst to get information about the code in the files, like what exports they have etc. This works great for new files that are created. But for files that are deleted we can't do that because we can't read the contents of deleted files...

Either we're less exact in our isX functions for files that are deleted. Or we'll have to come up with another method.

One idea I just had while typing this all out would be to keep a cache(-file?) of all files detected on startup and on file creation, and then just match against that cache when a file is deleted to know what kind of file it was.

@Tobbe Tobbe added topic/fully-integrated-dx help wanted good first issue and removed bug/needs-info More information is needed for reproduction labels Jan 16, 2024
@TheoOliveira
Copy link

A simpler idea if I understood the problem couldn't be just force to restart the server?

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

No branches or pull requests

2 participants