Open xendarboh opened 6 years ago
I traced the issue to lib/serve.js#L15. It works fine if I disable that line that emits the SIGUSR1
signal when restarting.
Also, I was able to fix the restarting behavior in my application by placing this in my server/index.js
file:
process.on('SIGUSR2', () => {});
However, I could not fix custom-server-micro in the same way. With the "fix", rather than crashing on restart it restarts once and then is hung. It's strange, considering I used that example as a reference for using micro/micro-dev with next.js in my app. My app has more going on now, not sure why difference... I'm running these inside a docker container.
Some more info from running it with npm
vs yarn
:
File changed: server.js - Restarting server...
User defined signal 2
npm ERR! code ELIFECYCLE
npm ERR! errno 140
npm ERR! @ dev: `micro-dev --watch server.js`
npm ERR! Exit status 140
npm ERR!
npm ERR! Failed at the @ dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'run', 'dev' ]
2 info using npm@5.6.0
3 info using node@v8.11.4
4 verbose run-script [ 'predev', 'dev', 'postdev' ]
5 info lifecycle @~predev: @
6 info lifecycle @~dev: @
7 verbose lifecycle @~dev: unsafe-perm in lifecycle true
8 verbose lifecycle @~dev: PATH: /usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/home/gizmoduck/src/TMP/NEXT/custom-server-micro/node_modules/.bin:/home/gizmoduck/bin:/home/gizmoduck/perl5/bin:/home/gizmoduck/bin:/home/gizmoduck/.yarn/bin:/home/gizmoduck/bin:/home/gizmoduck/perl5/bin:/home/gizmoduck/bin:/home/gizmoduck/.yarn/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
9 verbose lifecycle @~dev: CWD: /home/gizmoduck/src/TMP/NEXT/custom-server-micro
10 silly lifecycle @~dev: Args: [ '-c', 'micro-dev --watch server.js' ]
11 silly lifecycle @~dev: Returned: code: 140 signal: null
12 info lifecycle @~dev: Failed to exec dev script
13 verbose stack Error: @ dev: `micro-dev --watch server.js`
13 verbose stack Exit status 140
13 verbose stack at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:285:16)
13 verbose stack at emitTwo (events.js:126:13)
13 verbose stack at EventEmitter.emit (events.js:214:7)
13 verbose stack at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack at emitTwo (events.js:126:13)
13 verbose stack at ChildProcess.emit (events.js:214:7)
13 verbose stack at maybeClose (internal/child_process.js:925:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
14 verbose pkgid @
15 verbose cwd /home/gizmoduck/src/TMP/NEXT/custom-server-micro
16 verbose Linux 4.15.0-38-generic
17 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "dev"
18 verbose node v8.11.4
19 verbose npm v5.6.0
20 error code ELIFECYCLE
21 error errno 140
22 error @ dev: `micro-dev --watch server.js`
22 error Exit status 140
23 error Failed at the @ dev script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 140, true ]
From the log I notice I'm using node v8.11.4 which seems old... but that was by intention to match the version I have on target devices (Raspberry Pi). I can look into options to upgrade that and see if it has something to do with this issue.
Update: using node v10.13.0, similar behavior although it seems to take longer to restart.
micro-dev crashes when restarting.
To reproduce:
yarn dev
server.js
(with or without changes)crash
File changed: server.js - Restarting server... User defined signal 2 error Command failed with exit code 140. info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.