Skip to content

Say what is wrong when db:up cannot reach Docker - #11

Merged
walhalabi-code merged 2 commits into
mainfrom
fix/db-script-errors
Aug 31, 2026
Merged

walhalabi-code merged 2 commits into
mainfrom
fix/db-script-errors

Conversation

@walhalabi-code

Copy link
Copy Markdown
Owner

pm run db:up was docker compose up -d, so when Docker is not running the user gets Docker's own message:

unable to get image 'mongo:8': error during connect: Get
"http://%2F%2F.%2Fpipe%2FdockerDesktopLinuxEngine/v1.51/images/mongo:8/json":
open //./pipe/dockerDesktopLinuxEngine: The system cannot find the file
specified.

A named pipe, a URL-encoded path and an API version, and nowhere does it say "start Docker Desktop". For a library whose argument is that a failure should explain itself, passing that through unedited was a poor showing.

scripts/db.js now checks the two things that actually go wrong before handing over to compose - Docker missing, and the daemon down - and reads the compose output for the third, which is the common one once Docker IS running: port 27017 already held by another project's container. Each case says what to do, and all three mention the Atlas escape hatch.

Plain JavaScript, because it runs before anything is built, and no new dependency.

All three paths tested against real conditions: docker removed from PATH, DOCKER_HOST pointed at a dead pipe, and a second container holding 27017.

pm run db:up was docker compose up -d, so when Docker is not running the
user gets Docker's own message:

  unable to get image 'mongo:8': error during connect: Get
  "http://%2F%2F.%2Fpipe%2FdockerDesktopLinuxEngine/v1.51/images/mongo:8/json":
  open //./pipe/dockerDesktopLinuxEngine: The system cannot find the file
  specified.

A named pipe, a URL-encoded path and an API version, and nowhere does it say
"start Docker Desktop". For a library whose argument is that a failure should
explain itself, passing that through unedited was a poor showing.

scripts/db.js now checks the two things that actually go wrong before handing
over to compose - Docker missing, and the daemon down - and reads the compose
output for the third, which is the common one once Docker IS running: port
27017 already held by another project's container. Each case says what to do,
and all three mention the Atlas escape hatch.

Plain JavaScript, because it runs before anything is built, and no new
dependency.

All three paths tested against real conditions: docker removed from PATH,
DOCKER_HOST pointed at a dead pipe, and a second container holding 27017.
A scaffolded project promised interactive API docs and did not ship the package
that serves them, so the docs URL answered "Cannot GET".

setupSwagger treats swagger-ui-express as an optional peer: absent, it warns,
skips the browser UI and serves the spec at the json path alone. That is correct
behaviour for the library. The template was the problem - it asserted the URL in
four places while listing no dependency:

  src/banner.ts                 printed the docs URL on EVERY boot
  README.md                     "Interactive docs: ..."
  ai/skills/parse-boot.md
  ai/skills/parse-endpoint.md   told an assistant to go and check it

The banner is the worst of the four, because it points at the dead URL every
time the server starts.

Worth contrasting with the dashboard, which is also optional and handled
properly: it is opt-in on purpose - it carries the master key, which is a real
security decision - and banner.ts has a dashboardLine() reporting when it is not
mounted. Swagger has no such concern. Documentation for your own API should work
when the project starts, so the dependency is now declared rather than the
promise withdrawn.

Verified in a fresh project: swagger-ui-express installs, the project compiles,
and its five tests pass.
@walhalabi-code
walhalabi-code merged commit e7f7db6 into main Aug 31, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant