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

Restart on every rebuild #30

Open
antonyisoardi opened this issue Oct 4, 2018 · 10 comments
Open

Restart on every rebuild #30

antonyisoardi opened this issue Oct 4, 2018 · 10 comments

Comments

@antonyisoardi
Copy link

Not so sure if anyone else has experienced this, BUT!... I've noticed that the server is only being restarted on every second rebuild.

Rebuilds are successful every time, however in order for me to get the server restarted I have to make a second change.

@wmertens
Copy link
Collaborator

wmertens commented Oct 4, 2018 via email

@antonyisoardi
Copy link
Author

I'm on 2.2.5

@wmertens
Copy link
Collaborator

wmertens commented Oct 4, 2018 via email

@antonyisoardi
Copy link
Author

I'm not seeing it under version?

@rayalan
Copy link

rayalan commented Oct 21, 2018

As a separate confirmation, our team is seeing this problem more-or-less as a matter of course with 2.2.5 running under macOS. I'll try the beta and see how that goes.

@rayalan
Copy link

rayalan commented Oct 21, 2018

Some quick debugging suggests that this function is wrong:

afterEmit(compilation, callback) {
    if (this.worker && this.worker.isConnected()) {
      const signal = this._getSignal();
      if (signal) {
        process.kill(this.worker.process.pid, signal);
      }
      return callback();
    }

    this.startServer(compilation, callback);
  }

On the first pass, the code finds the connected worker, kills the server, and then returns the callback. The server is now dead (killed), but not restarted. On the second save, the if() clause doesn't trigger, so the server is started.

Note that this only happens when signal is set. It's possible there's a configuration issue here on my part (I don't think HMR is working properly in our configuration), but in general, my first thought is if start-server-webpack stops the server after a build, it should restart it again.

@rayalan
Copy link

rayalan commented Oct 21, 2018

Quick follow-up: our HMR was configured in poll mode, but start-server-webpack-plugin was configured with signal: true. When I use match 'signal: falsewithwebpack/hot/poll?500orsignal: truewithwebpack/hot/signal`, everything starts working.

Upon careful reading of the start-server-webpack-plugin, I think the documentation technically says this, but HMR hard enough for us to get configured (and not completely working until now) that I wonder if:

  • The documentation could be a little clearer about how important matching settings is?
  • If there's a way in code to catch the misconfiguration?

(One of the other tell-tales of our misconfiguration is that rs would sometimes exception out, because the kill command assumes the worker is still connected, but since the web server would stop every other build, sometimes the server wouldn't be working and the rs command would generate an exception.)

@antonyisoardi -- any chance the same issue for you?

Short version: I think this plugin works correctly as long as the configuration exactly matches the HMR configuration. However, if there is a mismatch, there are some subtle bugs where it would be nice if there was catastrophic failure.

@atifsyedali
Copy link

For my setup, signal: true with webpack/hot/signal didn't work for me.

But, signal: false with webpack/hot/poll worked for me.

@AlexMost
Copy link

Hey, so is there any way to enable restart on rebuild without HMR?

@tcosentino
Copy link

@AlexMost super late response, but I am using the @beta version without any hmr and getting a proper restart after each build

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

No branches or pull requests

6 participants