[ERR_UNKNOWN_SIGNAL]: Unknown signal: SIGUSR2
RonanQuigley opened this issue · 22 comments
When running the plugin (latest version) on windows 10, node version 9.7.1, the following error occurs:
``internal/process.js:168
throw new errors.TypeError('ERR_UNKNOWN_SIGNAL', sig);
^
TypeError [ERR_UNKNOWN_SIGNAL]: Unknown signal: SIGUSR2
at process.kill (internal/process.js:168:15)
at StartServerPlugin.afterEmit (D:\HotReloading\Old\Examples\uses-middleware\minimal-hmr\node_modules\start-server-webpack-plugin\dist\StartServerPlugin.js:77:19)``
When debugging that line in your code, I've noticed that SIGUSR2 is not a signal that's listed as being a part of the constants variable inside process.js. I don't really know how node.js' internal workings work but perhaps this is an issue with mac vs windows? Here's a picture of where the issue throw's an error and the offending variable:
I've tried changing the signal to the internal default SIGTERM, but that just terminates the signal. Any ideas on what the issue is, as this plugin worked great for my hot reloading workflow. Here's a repo that reproduces the issue (whether it happens on mac, I don't know). Just npm i followed by webpack to run the project, then navigate to the server dot index file and uncomment out the console.log('foo') or add in any new code to see the issue.
So what happens is that SSWP is now sending the USR2 signal when the server code gets rebuilt so you can use webpack/hot/signal
to do faster HMR than with webpack/hot/poll
.
Sorry that this is causing issues, I suppose this should have been a major version increase. You can disable it with signal: false
in the plugin configuration.
Oh! You're saying that Windows doesn't actually support SIGUSR2! Argh, ok disabling it by default.
I've tried disabling it by using signal : false. Whilst it works. It also means that hot reloading doesn't work. I've also tried using webpack/hot/signal instead but the same thing occurs - no hot reloading.
I don't know what the acronym SSWP means sorry.
As for the windows support; I can't tell as I don't have a mac; but if you check out the original image I posted, SIGUSR2 is not listed. I have had no luck finding any sort of documentation from node on their internals which makes it even more cryptic for me to work out a solution. (and what even is SIGUSR2?)
I ran through every other option listed and it either crashes or does nothing to keep hot reloading working.
Oh I should add. This plugin used to work fine when I used it last year. It was when I went to webpack 4 and updated this plugin to the latest that the issues arose. Reverting to an earlier version of your plugin would result in the same issue though.
Hmm, poll should always work. Are you maybe not including the webpack/hot/poll
module into the server build? It doesn't work if it's included as an external.
The npm publish didn't work, I'm asking Eric to fix it. In the meantime you can set signal
to false
in the plugin options; sorry about that.
In the next major release SSWP (start-server-webpack-plugin) will set up hot reload and signaling automatically. See the https://github.com/ericclemmons/start-server-webpack-plugin/tree/use-the-fork branch for a preview…
Just double checked: I've already tried doing what you've suggested. As I mentioned earlier, whilst it fixes the crash, the hot reloading won't work. Have you tried checking out the repo I posted for an example?
what I did was this
module.exports = {
mode : 'development',
entry: [ 'webpack/hot/poll?1000', "./server/index" ],
watch: true,
target: "node",
externals: [ nodeExternals({ whitelist: [ 'webpack/hot/poll?1000' ] }) ],
module: {
rules: [
{ test: /\.js?$/, use: "babel-loader", exclude: /node_modules/ },
],
},
plugins: [
new StartServerPlugin({
name: 'server.js',
signal : false
}),
new webpack.NamedModulesPlugin(),
new webpack.HotModuleReplacementPlugin(),
new webpack.NoEmitOnErrorsPlugin(),
new webpack.DefinePlugin({
"process.env": { BUILD_TARGET: JSON.stringify("server") },
}),
],
output: { path: path.join(__dirname, ".build"), filename: "server.js" },
};
And ah sorry, didn't realise that SSWP was obv that. Head frazzled with multiple things right now.
Just tried the fork you mentioned, but the installation doesn't work. Results in the following:
Error: Cannot find module 'start-server-webpack-plugin'
I tried running your repro, but I get this error:
$ webpack --hot -w
Webpack is watching the files…
Debugger listening on ws://127.0.0.1:9230/8da745c8-8568-4dad-a144-4324b8bcc777
For help see https://nodejs.org/en/docs/inspector
undefined:17
module.hot.accept(/*! ./server */ "./server/server.js"/*! ./server */ "./server/server.js", function(__WEBPACK_OUTDATED_DEPENDENCIES__) { (function(__WEBPACK_OUTDATED_DEPENDENCIES__) { (function () {
^^^^^^^^^^^^^^^^^^^^
SyntaxError: missing ) after argument list
at Object../server/index.js (/Users/wmertens/Downloads/unknown-signal-error-master/.build/server.js:779:1)
at __webpack_require__ (/Users/wmertens/Downloads/unknown-signal-error-master/.build/server.js:675:30)
at fn (/Users/wmertens/Downloads/unknown-signal-error-master/.build/server.js:54:20)
at eval (webpack:///multi_webpack/hot/poll?:2:18)
at Object.0 (/Users/wmertens/Downloads/unknown-signal-error-master/.build/server.js:802:1)
at __webpack_require__ (/Users/wmertens/Downloads/unknown-signal-error-master/.build/server.js:675:30)
at /Users/wmertens/Downloads/unknown-signal-error-master/.build/server.js:733:37
at Object.<anonymous> (/Users/wmertens/Downloads/unknown-signal-error-master/.build/server.js:736:10)
at Module._compile (module.js:643:30)
at Object.Module._extensions..js (module.js:654:10)
Hash: 156fbe5f7d52aa302ada
Version: webpack 4.1.0
Time: 2660ms
Built at: 2018-3-6 23:11:06
Asset Size Chunks Chunk Names
server.js 33.8 KiB main [emitted] main
Entrypoint main = server.js
[./node_modules/webpack/hot/log-apply-result.js] (webpack)/hot/log-apply-result.js 1.31 KiB {main} [built]
[./node_modules/webpack/hot/log.js] (webpack)/hot/log.js 1.03 KiB {main} [built]
[./node_modules/webpack/hot/poll.js?1000] (webpack)/hot/poll.js?1000 1.16 KiB {main} [built]
[./server/index.js] 580 bytes {main} [built]
[./server/server.js] 436 bytes {main} [built]
[express] external "express" 42 bytes {main} [built]
[0] multi webpack/hot/poll?1000 ./server/index 40 bytes {main} [built]
Not really sure how that weird hot.accept line was generated, looks like a bad substitution. In any case, indeed it looks as if it should work with the polling.
For testing that branch, after you download it and run npm i
in it, you should run npm link
in it so npm uses it, and then in your project run npm link start-server-webpack-plugin
, which should use the new plugin.
Odd, I just tried it with and without the flags you listed and I get no errors; another windows vs. mac quirk perhaps?
Either way, you don't need the flags: if anything you're running hot module replacement twice with the --hot flag that you added, which may be the problem. Did you just try running webpack on its own?
So I did an install with link, got that working now, however the update means that hot reloading doesn't work anymore and I have to manually restart webpack. I've tried it with both webpack/hot/poll?1000 and webpack/hot/signal. I also removed the externals option just in case either of the above weren't being whitelisted. You said it should work with polling, but do you mean webpack/hot/poll or am I missing something?
Interestingly the terminal does show the update being applied through HMR this time:
The config is now this for ref (I just removed the signal and debug options:
const path = require("path");
const nodeExternals = require("webpack-node-externals");
const StartServerPlugin = require("start-server-webpack-plugin");
module.exports = {
mode : 'production',
entry: [ 'webpack/hot/poll?1000', "./server/index" ],
watch: true,
target: "node",
externals: [ nodeExternals({ whitelist: [ 'webpack/hot/poll?1000' ] }) ],
module: {
rules: [
{ test: /\.js?$/, use: "babel-loader", exclude: /node_modules/ },
],
},
plugins: [
new StartServerPlugin({
name: 'server.js',
}),
new webpack.NamedModulesPlugin(),
new webpack.HotModuleReplacementPlugin(),
new webpack.NoEmitOnErrorsPlugin(),
new webpack.DefinePlugin({
"process.env": { BUILD_TARGET: JSON.stringify("server") },
}),
],
output: { path: path.join(__dirname, ".build"), filename: "server.js" },
};
Is it this?
/***/ }),
/***/ 0:
/*!**************************************************!*\
!*** multi webpack/hot/poll?1000 ./server/index ***!
\**************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
eval("__webpack_require__(/*! webpack/hot/poll?1000 */\"./node_modules/webpack/hot/poll.js?1000\");\nmodule.exports = __webpack_require__(/*! ./server/index */\"./server/index.js\");\n\n\n//# sourceURL=webpack:///multi_webpack/hot/poll?");
/***/ }),
/***/ "express":
/*!**************************!*\
!*** external "express" ***!
\**************************/
/*! no static exports found */
/***/ (function(module, exports) {
eval("module.exports = require(\"express\");\n\n//# sourceURL=webpack:///external_%22express%22?");
/***/ })
/******/ });
If so, I can see the build folder growing in size with new hot-update files being added every change. It's just nothing is reflected in the browser on refresh.
Very odd, are you sure you are on the use-the-fork
branch? Is there a file node_modules/start-server-webpack-plugin/dist/monitor.js
? That's the one that should have been auto-injected.
BTW, the [HRM]
output you had there is from the hot/poll module, so the HMR is working, it's just not doing what you expect :)
I just did clone of your repo link followed by an npm link in the directory I cloned it in, then an npm link in the repo I am using for this issue. Was that not correct? Can you give me a step by step on how it's done just so we're on the same page?
I can check tomorrow for the node_modules file you mentioned.
Yeah sorry I should've mentioned it was webpack 4.
I'm not sure what that command is for, I did try running it after updating to your latest version in the start-server-webpack-plugin folder. Could you bit a bit more specific on what you're meaning there?
Either way, I did make one mistake earlier: I forgot to checkout the use-the-fork branch! I've now got sswp showing up in the built server.js file, one such example being a console[type](`sswp> ${msg}`)
The following also now shows up in the console, does this look right:
However, still the same problem, hot reloading with the plugin doesn't work and requires a webpack restart to see the changes. The terrminal logs will also say cannot find update if I save when there is no changes made, which seems to imply there is an error? If I do make a change though, it does show up with update applied in the terminal
Do you still have this problem? Can you try with start-server-webpack-plugin@beta
?
Hey sorry for the delay, I had to put this down to work on other things.
I've taken a look using the latest (rc3). Good news is the signal error is gone, but there's still no hot updating being applied to the server. The only way to see a change requires a manual restart.
Do you have a windows machine you could use? Might be easier to see the problem that way.