Skip to content

fix(smoke): install node-service host deps + pin api to 1 replica in farm-smoke override - #29

Merged
sssaturX merged 2 commits into
santorifrom
cursor/smoke-node-deps-a86d
Apr 23, 2026
Merged

fix(smoke): install node-service host deps + pin api to 1 replica in farm-smoke override#29
sssaturX merged 2 commits into
santorifrom
cursor/smoke-node-deps-a86d

Conversation

@sssaturX

@sssaturX sssaturX commented Apr 23, 2026

Copy link
Copy Markdown
Owner

Problem

CI's Smoke (offline / PR) job fails with two successive issues:

  1. First failureCannot find module 'ioredis' in node-service/scripts/seed-mms-redis.cjs. The smoke shell script runs .cjs helpers on the host out of node-service/, needing ioredis / nats / ws / jsonwebtoken from node_modules. The CI job never ran npm ci in node-service/.
  2. Second failure (revealed once deps are installed) — Bind for 127.0.0.1:13000 failed: port is already allocated. The base docker-compose.yml declares api.deploy.replicas: 3 (production shape) but the smoke override publishes a fixed host port 13000. Only one container can bind it; replica main commit #2 aborts.

Fix

Three independent changes, all scoped to smoke-only config:

1. Install node-service host deps before running .cjs helpers

Shell scripts (scripts/docker-smoke-mms-{offline,live}.sh) get an ensure_node_service_deps guard that runs npm ci --no-audit --no-fund --prefer-offline in node-service/ only if any of ioredis / nats / ws / jsonwebtoken is missing. Fixes local reproduction too.

CI workflows (.github/workflows/ci.yml offline job and smoke-mms-live-nightly.yml) add actions/setup-node@v4 + explicit npm ci in node-service/ before the smoke step. Cache is warm across runs.

2. Pin api to 1 replica in the smoke override

docker-compose.farm-smoke-override.yml adds deploy.replicas: 1 on the api service. Compose deep-merges deploy, so the base deploy.resources block is preserved; production compose is untouched.

api:
  deploy:
    replicas: 1
  ports:
    - "127.0.0.1:13000:3000"

Verification

  • yaml.safe_load on both workflow files and the compose override — clean.
  • bash -n on both smoke scripts — clean.
  • CI run on this branch: greenSmoke (offline / PR) passes in 2m09s (gh run view 24861008276), together with node-service, ws-service, farm-spa, market-microstructure-service.
  • Host-side .cjs deps audited against every file in node-service/scripts/*.cjs:
    • ioredisseed-mms-redis.cjs
    • natsmms-offline-prove.cjs
    • wsmms-offline-prove.cjs, ws-mms-smoke.cjs
    • jsonwebtoken — inline node -e JWT sign in both smoke scripts

No production-path changes. This PR supersedes #28 (which carried only the replica fix).

Open in Web Open in Cursor 

cursoragent and others added 2 commits April 23, 2026 21:17
scripts/docker-smoke-mms-offline.sh and scripts/docker-smoke-mms-live.sh
run several .cjs helpers on the HOST out of node-service/ (seed-mms-redis,
mms-offline-prove, ws-mms-smoke, validate-api-mms-json, and an inline
jsonwebtoken sign) that require ioredis / nats / ws / jsonwebtoken from
node-service/node_modules.

The repo tracks node_modules in git per AGENTS.md, but fresh GitHub
Actions checkouts and devs with a local .gitignore customization hit:

  Error: Cannot find module 'ioredis'
  Require stack:
  - node-service/scripts/seed-mms-redis.cjs

Two-layer fix:

1. In both smoke shell scripts, guard an 'npm ci' that only runs when one
   of the required modules is missing from node-service/node_modules/.
   Fixes local reproduction for contributors.

2. In .github/workflows/ci.yml (smoke-mms-offline job) and
   smoke-mms-live-nightly.yml, add setup-node + explicit 'npm ci' inside
   node-service/ before the smoke step. Keeps CI self-documenting and
   allows actions/setup-node to cache the install between runs.

Co-authored-by: SaturX <sssaturX@users.noreply.github.com>
The base docker-compose.yml scales api to deploy.replicas: 3 (production
shape). The smoke override publishes a fixed host port mapping
127.0.0.1:13000 -> :3000, which only one container can bind at a time.
Docker Compose created 3 api containers and the 2nd/3rd failed with:

  Error response from daemon: failed to set up container networking:
  ... Bind for 127.0.0.1:13000 failed: port is already allocated

This aborted scripts/docker-smoke-mms-offline.sh (and -live.sh by the
same path) before any smoke checks could run.

Fix: set deploy.replicas: 1 on the api service in the smoke-only
override. Base production config is untouched.

Co-authored-by: SaturX <sssaturX@users.noreply.github.com>
@cursor cursor Bot changed the title fix(smoke): install node-service host deps before running .cjs helpers fix(smoke): install node-service host deps + pin api to 1 replica in farm-smoke override Apr 23, 2026
@sssaturX
sssaturX marked this pull request as ready for review April 23, 2026 22:10
@sssaturX
sssaturX merged commit 6e17a4c into santori Apr 23, 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.

2 participants