Repository navigation
Description
(heads up: this whole issue is ai-written but i believe it's a real issue and ran into it myself. I got gpt-5.6-sol to debug and write up this issue)
When two bb-app launchers use different data directories but the same server and daemon ports, the second
launcher can mistake the first launcher's server for its own.
If the second server child fails with EADDRINUSE, bb-app may still consider startup successful because its
health check receives a successful response from the existing server. It then requests a host enrollment key from
that existing server while saving the resulting host credentials in the second data directory.
After the existing server stops, the second launcher's host daemon connects to the server backed by its own
database. That database does not contain the enrolled host, resulting in INVALID_API_KEY or a 401 response
saying that the host is not registered.
Environment
bb-app: 0.35.1- Node.js: 26.5.1
- npm/npx: 11.17.0
- OS: Linux x86_64
Reproduction
In one terminal, start bb with a separate data directory:
BB_DATA_DIR=/tmp/bb-one npx bb-app@latest
In another terminal, start bb using another data directory but the same default ports:
BB_DATA_DIR=/tmp/bb-two npx bb-app@latest
The second server child cannot bind port 38886 and exits with:
listen EADDRINUSE: address already in use :::38886
However, the launcher's health request to http://127.0.0.1:38886 can be answered by the first server. The second
launcher may consequently report:
✓ Server listening on http://127.0.0.1:38886
It then requests an enrollment key from the first server and writes the resulting host identity to /tmp/bb-two/
auth.json.
After stopping the first launcher and starting the second one again, the host daemon fails with errors such as:
Server rejected host credentials — this host is not registered with the server.
or:
INVALID_API_KEY
The host ID from /tmp/bb-two/auth.json is present in /tmp/bb-one/bb.db, but absent from /tmp/bb-two/bb.db.
## Expected behavior
If the managed server child fails to bind its port, the launcher should fail startup and should not create or
modify host authentication state.
A health response from another process should not satisfy the managed child’s startup check.
## Actual behavior
The health check accepts a successful response from an unrelated server on the configured port. The launcher then
enrolls a host against that server while persisting the resulting credentials in a different data directory.
This leaves valid credentials associated with the wrong database and produces a misleading API-key error on
subsequent launches.
## Suspected cause
waitForHealth() checks whether the child process has exited and polls the configured health URL. There appears to
be a race where the unrelated server responds successfully before the failed child’s exit is observed.
More generally, an HTTP 2xx response only proves that a server is listening, not that it is the child process just
spawned by this launcher.
## Suggested fix
Give each managed launch a unique nonce or identity:
1. Generate a random startup nonce in the launcher.
2. Pass it to the server child.
3. Require the health endpoint to return that nonce.
4. Accept health only when it matches.
Alternatively, the health response could expose and verify an immutable launch identity that includes the expected
data directory.
The launcher should also stop immediately if its managed child exits during startup, even if the configured port
independently becomes healthy.
## Error-message improvement
INVALID_API_KEY is misleading here because this is bb’s internal daemon-host credential, not an inference-provider
API key.
A more actionable message would be:
> The saved host credential is not registered with this bb server. It may have been created by another server or
> data directory. Remove auth.json to re-enroll this host.
Unrecoverable host-authentication failures should also stop the restart loop and print recovery instructions.
## Workaround
Stop all bb instances, remove or move the mismatched host credential, and restart:
mv /tmp/bb-two/auth.json /tmp/bb-two/auth.json.invalid
BB_DATA_DIR=/tmp/bb-two npx bb-app@latest
This causes the host to enroll against the correct server database.
Activity
SawyerHood commentedon Aug 18, 2026
Reproduction & root-cause report: https://get-bb.github.io/reports/issues/1558.html
exporton the pr…The report has copy-paste repro steps, screenshots where the bug is visual, code permalinks at
16ceb3a54, and repro artifacts. It was independently re-run by a second agent (see its Verification section).Make bb-app verify its server child's identity on /health (#2162)