`node ace serve` leaves an orphaned supervisor behind, which brings the server back on the next file change
I maintainer di solito rispondono entro 5 giorni
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 48/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Stack tecnologico
- node.js, typescript
Direzione di ricerca
Start by reading the serve command’s staysAlive declaration and the supervisor behavior in @adonisjs/assembler that keeps watching after its child exits. Reproduce the issue by starting node ace.js serve --hmr, ending its parent shell, then changing a watched file; the report names no source file or test. Done means the orphaned supervisor exits or can be opted out, without disrupting normal watch mode.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Package version
7.6.0
Describe the bug
Package version
@adonisjs/core |
7.6.0 |
@adonisjs/application |
9.1.0 |
@adonisjs/assembler |
8.5.2 |
| Node / OS | 24.22.0 on macOS 26.6.2 |
Bug Description
Dev watch mode restarting a server that crashed is the right behaviour. What has no answer is the supervisor itself: the ace serve process never notices that the shell, terminal or IDE task that started it is gone. Kill that shell and the supervisor is reparented to pid 1 and keeps watching files. The next change to anything it watches starts the server again, so a process from a session that no longer exists comes back and takes the port that the next bun run dev needs, along with Vite's HMR port.
From the outside this shows up as "hot reload stopped working" or "port 3333 is already in use", and the process is easy to lose track of: the supervisor never listens on anything itself, only the child it starts does, so a port scan won't find an orphan whose server has died. The only way left to kill it by hand is pgrep "ace.js serve".
serve is declared staysAlive: true, and the supervisor's reaction to a dead child is deliberate: "Underlying HTTP server died. Still watching for changes" (@adonisjs/assembler 8.5.2). That's right while the shell is still there. What nothing checks is the other direction: whether anyone is still there to want that server.
What this costs in practice
One morning, a bun run dev on an unrelated project failed before it ever bound a port: the run died while setting up the HMR watcher, out of file descriptors. What the machine was carrying at that moment:
$ pgrep -fl "ace.js serve" | wc -l
29
$ pgrep -fl "ace.js serve" # 26 x `ace.js serve --hmr` in one project, 3 x `ace.js serve` in another
81234 node ace.js serve --hmr
...
$ lsof -ti :3334 :3335 :3336 # and not one of them listening on anything
Twenty-nine supervisors from two projects, none of them wanted any more, none of them listening, none of them findable by port, with 26 of them still holding a watcher over a project tree, ~58 MB of RSS each, about 1.7 GB in total. In a terminal they are invisible: the windows that started them were closed days ago, and a port scan (the usual way to find a leftover dev server) finds nothing at all, because the supervisor only ever holds a port while a child of its own is alive. Getting rid of them means pgrep -f "ace.js serve" | xargs kill, by name, by hand, on the chance that you notice them.
The new run was the one that had to open one watcher too many, and it was the one that failed. That project had nothing to do with any of the 29.
Reproduction
$ zsh -c 'node ace.js serve --hmr' # any shell, terminal or IDE task
...
│ Server address: http://127.0.0.1:3333 │
│ Mode: hmr │
[ info ] watching file system for changes...
$ ps -ax -o pid=,ppid=,etime=,command= | grep -E 'ace\.js serve|bin/server\.ts'
2330 51308 00:12 zsh -c node ace.js serve --hmr
2333 2330 00:11 node ace.js serve --hmr
2375 2333 00:10 node ... bin/server.ts <- listening on 3333
$ kill -9 2330 # the shell goes away
$ ps -ax -o pid=,ppid=,etime=,command= | grep -E 'ace\.js serve|bin/server\.ts'
2333 1 00:20 node ace.js serve --hmr <- reparented, still watching
2375 2333 00:19 node ... bin/server.ts <- still listening on 3333
$ touch config/app.ts # one file change
2333 1 00:30 node ace.js serve --hmr
2627 2333 00:06 node ... bin/server.ts <- restarted, 3333 taken again
What I would like
A dev supervisor belongs to the session that started it. If its parent is gone (ppid === 1, or the pid it was started with no longer exists), it should stop watching and exit, instead of waiting for a file change it can never be told about. If that's too aggressive for some setups, an opt-out flag (--keep-alive, or the reverse) would still be better than the current default. And when the child is dead, something other than SIGKILL from a ps sweep to leave the "still watching" state: it has no address and no port of its own to be found by.
Related
- #5164:
node ace testnever exits while anything is still holding the event loop open (same family, different command)
Reproduction repo
No response
- Lingua principale
- TypeScript
- Stelle
- 19.2k
- Fork
- 670
- Merge medio
- 7g 6h
- PR unite (30g)
- 9
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di adonisjs/core
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
adonisjs/core#5169 · 2 commenti ·
I maintainer di solito rispondono entro 5 giorni
-
`node ace test` prints `PASSED` and never exits while anything is still holding the event loop openAperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
I maintainer di solito rispondono entro 5 giorni
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
adonisjs/core#5158 · 1 reazione ·
I maintainer di solito rispondono entro 5 giorni
-
Barrel file not using custom `directories`Forse di nuovo libera Una pull request per questa issue è stata chiusa senza essere unita. ApertaType: Enhancement
Difficoltà 3/5 1-2 giorni Idoneità per principianti 58/100
adonisjs/core#5133 · 1 commento ·
I maintainer di solito rispondono entro 5 giorni
-
Request loggerForse di nuovo libera @thetutlage l’ha presa 164 giorni fa e non c’è nessuna pull request aperta. ApertaType: Feature Request
adonisjs/core#5102 · 5 commenti · 3 reazioni · 1 assegnatario ·
I maintainer di solito rispondono entro 5 giorni
Tutte le issue di adonisjs/core
Issue simili
-
triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 1 giorno
-
🎙️ task - drop the raw `./node_modules/.bin/rhachet roles boot` line from bhuild's feedback templateAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
ehmpathy/rhachet-roles-bhuild#639 ·
I maintainer di solito rispondono entro 1 giorno
-
e2e-failure ready-to-code
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
redhat-developer/rhdh-plugin-export-overlays#4650 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
I maintainer di solito rispondono entro 13 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
omdsh-dev/DSH-better-sidebar#1098 ·
I maintainer di solito rispondono entro 2 giorni