This has been annoying me for some time:
Error from chokidar (/home/brian/tree/personal/relixir/robotica/robotica_face/assets/node_modules/css-loader/dist/runtime): Error: EMFILE: too many open files, watch '/home/brian/tree/personal/relixir/robotica/robotica_face/assets/node_modules/css-loader/dist/runtime/api.js'
This message gets displayed for every file in the assets directory, when starting the dev instance. If I stop other running programs, close browser tabs, it will come good temporary, but then go bad again. Only sure fix is to reboot my computer.
Phoenix is the only thing that seems to be affected, and as far as I can tell it isn’t actually affecting running of the application.
My computer is Debian/bullseye.
This is the only running copy of elxir running on this computer.
Wondering if there is something on my system - maybe even the Linux kernel - that is leaking open files.
Have you checked your total limit of how many open files can you have at maximum?
Did You make any changes to the watchers configuration?
No. I didn’t make any changes. Apart from changing --watch-stdin
with --watch
.
Did You change this for Webpack 5?
Maybe like this?
node: [
"node_modules/webpack/bin/webpack.js",
"--mode",
"development",
"--watch",
"--watch-options-stdin",
cd: Path.expand("../assets", __DIR__)
]
1 Like
kokolegorille:
--watch-options-stdin
Hmmm. I am not familiar with this --watch-options-stdin
. The info I saw - somewhere - strongly implied I should drop --watch-stdin
.
e.g. the top two google results for watch-stdin:
opened 04:14PM - 27 Oct 20 UTC
closed 05:40PM - 04 Dec 20 UTC
stale
opened 02:05AM - 11 Oct 20 UTC
closed 04:05AM - 11 Oct 20 UTC
### Environment
phoenix 1.5.5
elixir 1.10.3-otp-23
erlang 23.0.1
… nodejs 12.18.4
npm 6.14.6
OSX 10.15.6 (19G2021)
Webpack 5
```
% mix phx.server
Compiling 59 files (.ex)
Generated morphic_pro app
[info] [alarm_handler: {:set, {:system_memory_high_watermark, []}}]
[info] Running MorphicProWeb.Endpoint with cowboy 2.8.0 at 0.0.0.0:4001 (https)
[info] Access MorphicProWeb.Endpoint at https://localhost:4001
[webpack-cli]
TypeError: Cannot read property 'tap' of undefined
[error] Task MorphicProWeb.Endpoint started from #PID<0.1043.0> terminating
** (stop) :watcher_command_error
(phoenix 1.5.5) lib/phoenix/endpoint/watcher.ex:37: Phoenix.Endpoint.Watcher.watch/3
(elixir 1.10.3) lib/task/supervised.ex:90: Task.Supervised.invoke_mfa/2
(stdlib 3.13) proc_lib.erl:226: :proc_lib.init_p_do_apply/3
Function: &Phoenix.Endpoint.Watcher.watch/3
Args: ["node", ["node_modules/webpack/bin/webpack.js", "--config", "webpack.dev.config.js", "--color", "--bail"], [cd: "/Users/joshchernoff/Dev/morphic.pro/assets"]]
```
Looks like watch is broken with the webpack 5 upgrade.
Also, note `--watch-stdin` is no longer an option
Which links to the fix:
committed 09:03AM - 02 Nov 20 UTC
This allows Webpack 5.
Fixes https://github.com/phoenixframework/phoenix/iss… ues/4020
From the docs:for watch-options-stdin
:
Stop watching when stdin stream has ended
Apparently I have 90 copies of webpack running. Oh, that would explain it.
Will make the change, kill my webpacks, and hopefully that will fix this.
Thanks!
It would be good if there was an authoritative source somewhere of correct changes required to the webpack stuff from the standard phoenix template.
See also Webpack error after upgrading mini-css-extract-plugin@1.6.2 - #3 by derek-zhou for an example of just another problem this has caused me.
You might find reference here…
phoenixframework:master
← cw789:master
opened 09:08AM - 02 Nov 20 UTC
**Revision**
- Including v1.x version annotation within package.json
- Again… "source-map" instead of "eval-cheap-source-map" for now
Background "source-map":
Terser plugin doesn't work with "eval-cheap-module-source-map".
Suggestion for additional PR (if it will improve build time):
```
const webpack = require('webpack');
...
plugins: [
new webpack.EvalSourceMapDevToolPlugin({
exclude: ['./vendor/**/*.js']
})
]
devtool: false
```
---
**Initial**
Including update to webpack 5.
Some things are probably opinionated.
- Obvious "fixed" versions within package.json (real version is anyway in package-lock.json)
- No license field in package.json as not defined it must be MIT ...
Edit:
- Replaced `optimize-css-assets-webpack-plugin` with `css-minimizer-webpack-plugin` (Thx @optikfluffel)
- `source-map` instead of `eval-cheap-source-map`
~Has open Issue (warning in CLI, but seem to work anyway): https://github.com/webpack/webpack-cli/issues/1918~
Concerns discussion: https://elixirforum.com/t/upgrade-to-webpack-5/35010
Resolve #4020
Good point. I guess I should compare my assets directory with the values from the git source at phoenix/installer/templates/phx_assets at master · phoenixframework/phoenix · GitHub