-
Notifications
You must be signed in to change notification settings - Fork 28
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
Webpack dev server with rails-erb-loader and spring hangs #47
Comments
Yeah, I've been meaning to open an issue for this for a while. We've been hitting this problem ourselves. I think that, as you suggest, that it's a bug in spring. I added a timeout recently in #46 that should kill the ruby process, but it the compile process never ends, nor emits the converted code and the process doesn't end, preventing the loader from completing. Tbh I'm not sure what to do about this. Definitely open to suggestions. This is a new problem for us, but I'm not sure if it's to do with a spring update or just an increase in the number of files we're transpiling, but it's pretty bad. |
@doits did you use add a JS timeout, or did you use the existing Ruby-based timeout option? |
@rhys-vdw I did not realize those where two different timeouts. I did use the ruby-based timeout. Just now I simply patched function transformSource (runner, config, source, map, callback) {
var child = execFile(
runner.file,
runner.arguments.concat(
runnerPath,
ioDelimiter,
config.engine,
config.timeout
),
{
timeout: 10000
},
function (error, stdout, stderr) {
... With this, compilation always runs through even with cold spring and it looks like everything is compiled correctly. A shot in the dark: Might it be that spring is forking a new process when run through |
Interesting! Wouldn't the timeout cause an error to be raised, rather than a successful compilation?
Ah, interesting. In my experience running after
Would you be interested in opening a PR with these changes, removing the Ruby timeout, and replacing it with the more reliable JS timeout? If so, make sure that the In my experience the existing timeout option doesn't address this at all. I added it to get more feedback on the issue, but it's never triggered in our dev environment. |
Or alternatively we could update to have two arguments |
Or, if your theory is correct, perhaps switching back to |
I have a similar problem, but I'm suspecting more of the interaction between behavior of webpack caching and the return of the ERB on error. My suspicion is because when i turn off the webpack caching |
@chaffeqa okay, that's pretty good to know. Any idea what we could do to fix it? |
Don't make errors 😉 It's a bandaid, but I added an var child = execFile(
runner.file,
runner.arguments.concat(
runnerPath,
ioDelimiter,
JSON.stringify(config)
),
{
maxBuffer: 1024 * 1000,
timeout: 30 * 1000,
},
function (error, stdout, stderr) {
// ...
}
) So if something errors out silently in ERB parsing, eventually the loader will error out. 🤕 |
haha no I meant Sure thing on the PR! |
Closed by #54... Hopefully. Let me know how 5.3.0 works for you. |
@rhys-vdw Still hanging on 5.5.0, it hangs on [Webpacker] Compiling… until I run |
I do this with /* put this in file like /config/webpack/loaders/erb.js */
/* global process:false */
module.exports = {
test: /\.erb$/,
enforce: "pre",
exclude: /node_modules/,
use: [{
loader: "rails-erb-loader",
options: {
runner: (/^win/.test(process.platform) ? "ruby " : "") + "bin/rails runner",
env: {
...process.env,
DISABLE_SPRING: 1,
},
},
}],
} Edit 1: Add missing quote |
@PikachuEXE Thanks, haven't had any issues in the last days after your fix! If someone is wondering, that fix goes into |
Maybe worth putting the example in README? |
@PikachuEXE I didn't notice you were the gem mantainer. First, congrats. Second, yes, for sure, it was bothering me big time and googling my way here wasn't easy. Add it to the readme! |
@feliperaul if you're experiencing hangs you should also set the |
@PikachuEXE I just ran into this same thing (on v5.5.2). It looks like that change never made it into the readme |
Sorry just added the example to README |
This was originally posted at webpacker rails/webpacker#785.
Using rails-erb-loader@^5.2.1 and webpacker gem 3.0.1, rails 5.1.4 and spring 2.0.2.
I've the problem that in my current project, webpack-dev-server hangs when first started:
It sometimes hangs at some other point, eg.:
so the hang is not consistent, but it always displays some
.erb
at the end of output.If I cancel the dev server and restart it, it goes through without a problem:
I noticed that it happens only when spring was not started before. If spring is started already (e.g. because of a
rails console
), the compilation goes through on first try without the need to cancel it first.Additionally, when I disable spring by commenting out the spring loader from
bin/rails
, or by usingDISABLE_SPRING=1 ./bin/webpack-dev-server
it always goes through without a problem, too. So I suspect it to be the combination of spring and the rails erb loader that makes it hang somehow (or is anything else callingbin/rails
during compiling?)I tried to set a timeout for
rails-erb-loader
by editingnode_modules/rails-erb-loader/index.js
, suspecting a hang while compiling the erb assets, but this did not change anything (still hangs).How can we debug this further to see where exactly it hangs and why?
The text was updated successfully, but these errors were encountered: