Opened 5 months ago
Last modified 5 months ago
#63605 new defect (bug)
npm run dev: file watcher sometimes deletes uploaded files
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | Awaiting Review | Priority: | normal |
| Severity: | normal | Version: | |
| Component: | Build/Test Tools | Keywords: | |
| Focuses: | Cc: |
Description
I've noticed that, when the npm run dev command is running the file watcher, if you try to upload a file, the file watcher will sometimes delete the file immediately after it has been created.
Unfortunately it seems to happen only intermittently, and I haven't found a reliable way of reproducing it consistently. I've seen it happen sometimes when uploading an image to the Media Library, and I've also seen it happen when uploading a font file using the block editor. You can see an example of the latter here: https://core.trac.wordpress.org/ticket/63568#comment:20
When it does happen, the output from npm run dev will look something like this:
Running "_watch" task ... >> File "src/wp-content/uploads/fonts/O-Reilly-Sans-Regular.ttf" added. Running "clean:dynamic" (clean) task >> 1 path cleaned.
The 1 path cleaned indicates that the file watcher just deleted a file for some reason (normally it says 0 paths cleaned).
I searched Trac to see whether this has been reported before, and I found #49275 which is kind of a different issue but appears to be similar. The author made the following suggestion which seems like it would fix both issues:
Is there a way to maybe only "watch" the wp-content files that core has and nothing else?
Following the conversation from this point:
Replying to siliconforks:
I was unable to reproduce this with this env vars
Environment
What was frustrating me was this message:
Warning: Maximum call stack size exceededThat after a while ended in a
FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memoryI commented in Slack and @desrosj told me that having a lot of plugin was correlated with this error (just having the plugins, not even activated). So I moved all my plugins (~50) away from the folder, and the problem has been solved
Now I upload the font and:
Then I removed the font, uploaded again and:
Note the difference?
In the first one it says: 0 paths cleaned
In the second one it says: 1 paths cleaned
Not sure, but the problem could be somewhere around here
all: { files: [ SOURCE_DIR + '**', '!' + SOURCE_DIR + 'js/**/*.js', // Ignore version control directories. '!' + SOURCE_DIR + '**/.{svn,git}/**' ], tasks: ['clean:dynamic', 'copy:dynamic'], options: { dot: true, spawn: false } }, 'js-enqueues': { files: [SOURCE_DIR + 'js/_enqueues/**/*.js'], tasks: ['clean:dynamic', 'copy:dynamic-js', 'uglify:dynamic'], options: { dot: true, spawn: false } },