[Bug] Pool exits at startup when the delegate lookup fails
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 70/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- javascript, node.js
Research direction
Start in server/src/app.js at initDelegate() (L131-L138) and server/src/modules/store.js L313. Read how updateDelegate() returns undefined and triggers process.exit. Implement bounded retry for transport or node-readiness failures, keeping the web server up and /api/health at 'starting'. Done when the pool no longer exits on transient delegate lookup failure and reports starting until a node answers.
Written by the indexing model from the issue text.
Description
Summary
A failed delegate lookup at startup is fatal: initDelegate() exits the process for any unsuccessful getDelegate response, so a node that is reachable but not finished loading is treated exactly like an account that is not a delegate. Under a process manager the pool is then restarted repeatedly until a node serves delegate data.
Steps to reproduce
- Run a pool whose
node_ADMlist reaches no node that can answer a delegate query yet. The usual case is a host where the pool and its local ADAMANT node start together after a reboot: the node answers/api/node/statuswhile it is still rebuilding its memory tables, and answers the delegate query only later. - Start the pool under PM2 or systemd (no TTY).
- Watch the log and the restart counter.
Expected behavior
The pool stays up, retries the lookup with a bounded backoff, and reports status: "starting" through /api/health until a node answers. It already has both pieces: a multi-node list with failover (remote nodes next to http://localhost:36666) and a starting state in the health snapshot. A hard exit should be reserved for a response that actually proves the account is not a delegate, because that is a configuration error an operator must fix.
Actual behavior
initDelegate() (server/src/app.js#L131-L138) calls store.updateDelegate() (server/src/modules/store.js#L313), which returns undefined whenever getDelegateResponse.success is false, whatever the reason. The caller logs Failed to get delegate for <address>. Cannot start Pool. and calls process.exit(EXIT_CODE_ERROR).
Consequences on a host where the node and the pools boot together:
- The process manager restarts the pool a few times at every boot. The restart counter grows for a reason that is not a fault, which hides a genuine restart loop from monitoring that alerts on it.
- An encrypted pool comes back locked after each restart, so the unnecessary restarts multiply operator unlocks.
- Nothing in
/api/healthreflects the situation, because the process is gone instead of reportingstarting.
A contributing factor sits in adamant-api 3.1.0, and may deserve its own issue there:
NodeManager.updateNodes()callsthis.ready()unconditionally (src/helpers/healthCheck.ts#L143-L145), soonReadyfires even afterchooseNode()bailed out with "All of N nodes are unavailable".checkNodes()(same file,#L327-L345) counts a node as active once it answers/api/node/status, without looking atloadedorsyncing.
Together they make the pool set setNodeReady(true) and start the delegate lookup while no node can serve it, which turns the fatal exit above from an edge case into something that happens at every boot.
Environment
Reproduced with pool v3.1.0 under PM2 on Ubuntu 26.04 LTS, with the pool and an ADAMANT node on the same host. The code path is unchanged on dev (3.1.1).
Suggested fix
In initDelegate(), retry updateDelegate() with a bounded backoff while the lookup fails for a transport or node-readiness reason, keep the web server and the control socket running, and keep /api/health at starting. Exit only for a response that identifies the account as not a delegate. UPDATE_DELEGATE_INTERVAL already re-runs store.updateAll() once the pool is up, so the startup path is the only place that needs the retry.
- Dominant language
- JavaScript
- Stars
- 512
- Forks
- 9
- PR merge metrics
- No merged PRs in 30d
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Adamant-im/pool
-
High priority NodeJS Security Task
Difficulty 3/5 1-2 days Newbie friendliness 50/100
Adamant-im/pool#17 ·
Similar issues
-
Bug Tests
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
JSPrismarine/JSPrismarine#3384 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
desec-io/desec-stack#1312 ·
Maintainers usually reply within 14 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
blowhorn-ai/blowhorn-mcp#70 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
xdelmo/Portfolio-minimal#613 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 86/100
chrisk123999/chris-premades#708 ·
Maintainers usually reply within 1 day