fix(aztec-cli): release TXE port and kill bb children on shutdown#22730
Merged
dbanks12 merged 4 commits intomerge-train/fairiesfrom Apr 24, 2026
Merged
fix(aztec-cli): release TXE port and kill bb children on shutdown#22730dbanks12 merged 4 commits intomerge-train/fairiesfrom
dbanks12 merged 4 commits intomerge-train/fairiesfrom
Conversation
Ctrl-C during `aztec test` left the TXE node and any in-flight `bb` child running, keeping port 8081 bound and blocking subsequent runs. Fix at two layers: - `aztec.sh`: enable job control so the backgrounded TXE gets its own process group, then signal the whole group on cleanup (trap EXIT/INT/ TERM/HUP, SIGTERM then SIGKILL escalation, `wait`). - `startTXE`: push an `httpServer.close()` callback into `signalHandlers` so the port is released before `process.exit` under normal shutdown. - `executeBB`: forward SIGINT/SIGTERM/SIGHUP to the spawned `bb` child so it doesn't survive as an orphan when the parent exits. Fixes #22725.
Drop the SIGTERM → grace → SIGKILL escalation loop in favor of the single `kill -TERM` + `wait` pattern used by ci3/run_test_cmd and ci3/parallelize_strict. The TS-layer signal forwarding in executeBB covers the "bb ignores SIGTERM" case, making the shell-level SIGKILL escalation redundant.
ludamad
reviewed
Apr 23, 2026
| export LOG_LEVEL="${LOG_LEVEL:-"error;trace:contract"}" | ||
| # Enable job control so the backgrounded TXE gets its own process group. | ||
| # Signalling the group on cleanup reaches node + any bb descendants, which | ||
| # otherwise get orphaned to init and keep the port bound after Ctrl-C. |
Collaborator
There was a problem hiding this comment.
Does this need its own process group for graceful cleanup?
Contributor
Author
There was a problem hiding this comment.
Probably not honestly. This should never be hit if the TS signal handling is all sane. Edit: should never be a concern here in bash*
Collaborator
There was a problem hiding this comment.
The TS changes are less controversial to me
Contributor
Author
There was a problem hiding this comment.
Removed bash changes
aztec test
charlielye
approved these changes
Apr 24, 2026
Contributor
charlielye
left a comment
There was a problem hiding this comment.
Hopefully the bb part of this becomes obsolete with this following PR, as in this path bb will kill itself when it parent dies (dark). but this looks fine for quick fix.
This was referenced Apr 24, 2026
Collaborator
|
✅ Successfully backported to backport-to-v4-staging #22768. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Ctrl-C (or any SIGINT/SIGTERM) during
aztec testcould leave the TXE node still listening on its port and in-flightbbchildren still running, blocking subsequent runs withEADDRINUSE. Fixes #22725.Why it happens
Two gaps in the TXE shutdown path:
startTXE(yarn-project/aztec/src/cli/cmds/start_txe.ts) bound the HTTP listener but registered no shutdown callback with the outersignalHandlersarray thataztecStartpasses toinstallSignalHandlers(yarn-project/aztec/src/cli/aztec_start_action.ts:94). Every otherstart*function in that file (startNode,startBot,startArchiver,startP2PBootstrap,startProverAgent,startProverBroker) already wires itself in this way — TXE was the odd one out. The listener could outliveprocess.exitunder adversarial timing and hold the port.executeBB(yarn-project/bb-prover/src/bb/execute.ts:90) spawnedbbwith no signal plumbing. If the node parent received SIGINT/SIGTERM, those signals were not propagated tobb, so the child became an orphan under init.Changes
startTXE: acceptsignalHandlers, push() => httpServer.close()so the port is released cleanly on SIGINT/SIGTERM. Brings TXE in line with the otherstart*functions.aztec_start_action: passsignalHandlersintostartTXE.executeBB: forward SIGINT/SIGTERM/SIGHUP to the spawnedbbchild, removing the handlers on close so they don't leak across calls.Test plan
yarn buildpasses for touched packages.yarn format+yarn lintclean foraztecandbb-prover.aztec test --workspace, Ctrl-C mid-run, confirm no orphanednode/bbprocesses and that re-running starts cleanly.pkill -TERM -f 'aztec start --txe'mid-run, same check.