dev-runner leaves sockets in use after quitting
AtkinsSJ opened this issue · 2 comments
AtkinsSJ commented
I'm running on Linux, and this happens a bit inconsistently for me.
Steps:
dev-runner ./run-phoenix-http.json5
- Enter
stop
to shut it down - Wait until all
node
processes related to it have exited dev-runner ./run-phoenix-http.json5
again- See errors in the log about the addresses being in use.
❯ dev-runner ./run-phoenix-http.json5
src/main.js → dist/bundle.js...
created dist/bundle.js in 602ms
src/main_puter.js → dist/bundle.js...
created dist/bundle.js in 516ms
[term.http:err] node:events:497
[term.http:err] throw er; // Unhandled 'error' event
[term.http:err] ^
[term.http:err]
[term.http:err] Error: listen EADDRINUSE: address already in use 0.0.0.0:8082
[term.http:err] at Server.setupListenHandle [as _listen2] (node:net:1893:16)
[term.http:err] at listenInCluster (node:net:1941:12)
[term.http:err] at doListen (node:net:2096:7)
[term.http:err] at process.processTicksAndRejections (node:internal/process/task_queues:83:21)
[term.http:err] Emitted 'error' event on Server instance at:
[term.http:err] at emitErrorNT (node:net:1920:8)
[term.http:err] at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
[term.http:err] code: 'EADDRINUSE',
[term.http:err] errno: -98,
[term.http:err] syscall: 'listen',
[term.http:err] address: '0.0.0.0',
[term.http:err] port: 8082
[term.http:err] }
[term.http:err]
[term.http:err] Node.js v21.6.2
[term.http] STOPPED
[shell.rollup:err] rollup v3.21.4
[shell.rollup:err] bundles src/main_puter.js → dist/bundle.js...
[term.rollup:err] rollup v3.23.0
[term.rollup:err] bundles src/main.js → dist/bundle.js...
[shell.http:err] node:events:497
[shell.http:err] throw er; // Unhandled 'error' event
[shell.http:err] ^
[shell.http:err]
[shell.http:err] Error: listen EADDRINUSE: address already in use 0.0.0.0:8080
[shell.http:err] at Server.setupListenHandle [as _listen2] (node:net:1893:16)
[shell.http:err] at listenInCluster (node:net:1941:12)
[shell.http:err] at doListen (node:net:2096:7)
[shell.http:err] at process.processTicksAndRejections (node:internal/process/task_queues:83:21)
[shell.http:err] Emitted 'error' event on Server instance at:
[shell.http:err] at emitErrorNT (node:net:1920:8)
[shell.http:err] at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
[shell.http:err] code: 'EADDRINUSE',
[shell.http:err] errno: -98,
[shell.http:err] syscall: 'listen',
[shell.http:err] address: '0.0.0.0',
[shell.http:err] port: 8080
[shell.http:err] }
[shell.http:err]
[shell.http:err] Node.js v21.6.2
[shell.http] STOPPED
After doing the same again, I only had the :8080
server fail to start. Then a third time, they both succeeded. But it definitely varies.
KernelDeimos commented
A few things come to mind:
- Although stop and Ctrl+C should be the same, I think I've only observed this once or twice and I usually use Ctrl+C
- This might be an issue in dev-runner itself
AtkinsSJ commented
A workaround might be to scan for available ports (like the Puter dev server does) instead of hard-coding them. That doesn't fix this issue, but would make it less of a problem, and would generally be good to do as we don't know what ports someone's system might be using already.