Skip to content

Promote develop to main: the sync agent coupling, pinned - #866

Merged
sridharkalaibala merged 2 commits into
mainfrom
develop
Sep 17, 2026
Merged

sridharkalaibala merged 2 commits into
mainfrom
develop

Conversation

@sridharkalaibala

Copy link
Copy Markdown
Contributor

Two commits, no runtime change. Kept level with main so the next exe is built from a branch that matches what has been reviewed.

Carries

The sync agent finds its modules by a route nobody can see (#865).

The agent declares bson, dotenv and mongodb and ships with none of them. Verified on the installed app: resources/sync-agent/ holds package.json, src/ and sync-config.json and no node_modules, while the log shows it syncing 91 orders.

It works because src/server.js puts the API's node_modules on NODE_PATH for the API, and src/sync-agent-manager.js spawns the agent with ...process.env. So cloud sync depends on the API starting first, on a variable set for a different purpose, and on a spread operator that reads like boilerplate. Remove any one and it dies with MODULE_NOT_FOUND on a customer machine and nowhere else.

Pinned with four tests rather than rewired: shipping a second copy of mongodb would be dead weight, the design is right, and changing a working spawn mid-handover is not worth it. One of the tests fails if the agent ever grows a dependency the API does not carry, which would otherwise surface as a sync that stopped, at night, on a till.

The packaging step also stops printing a warning on every correct build telling whoever saw it to run npm install in the Cloud agent, which would have made every installer larger to fix nothing.

After this

Re-stage with npm run build or npm run publish. Then on the kitchen machine: npm run check:installed, Core Settings, both switches on, press Test the sound.

Do not squash.

The agent declares bson, dotenv and mongodb and ships with none of them.
Verified on a real installed app: resources/sync-agent/ holds
package.json, src/ and sync-config.json, and no node_modules at all.

It works anyway, and the reason is three files apart from each other,
none of which mentions the others. server.js puts the API's node_modules
on process.env.NODE_PATH, for the API. sync-agent-manager spawns the
agent with ...process.env. The agent inherits that and resolves its three
packages from the API's copy, which already carries all of them.

So cloud sync depends on the API having started first, on a variable set
for a different purpose, and on a spread operator. Remove any one and it
dies with MODULE_NOT_FOUND on a customer machine and nowhere else.

That is not a complaint about the design - a second copy of mongodb in
the installer would be real weight for no gain. It is a complaint about
the coupling being invisible, which is the shape of every fault found in
this app today: correct code silently relying on something nobody could
see from where they were standing.

Pinned rather than rewired. Cloud sync is load-bearing and a test costs
nothing, while changing a working spawn costs a shop's orders if it is
wrong.

The packaging step also stops calling the normal case a warning. It
printed "WARNING: agent copied without node_modules - run npm install in
the Cloud agent first" on every correct build, and following that advice
would have made every installer larger to fix nothing. A warning that
fires when everything is right is one people learn to scroll past, and
then the real one scrolls past too.
…les-on-purpose

The sync agent finds its modules by a route nobody can see
@sridharkalaibala
sridharkalaibala merged commit 3f09489 into main Sep 17, 2026
21 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