Skip to content

fix: Stop start-up quietly on a reload and run the dev bot on shared's source - #230

Merged
Kkkermit merged 1 commit into
developfrom
testify/bugfix-13
Nov 19, 2026
Merged

Kkkermit merged 1 commit into
developfrom
testify/bugfix-13

Conversation

@Kkkermit

Copy link
Copy Markdown
Owner

What this changes

Three problems with npm run dev:all on macOS:

  • A reload during start-up no longer prints contradicting lines. tsx watch restarts with SIGTERM, and shutdown() closed the database while main() was still starting. The log then showed "Connected to MongoDB", followed by the log history failing with MongoNotConnectedError and "Lost the connection to MongoDB". There are three parts to the fix:
    • isShuttingDown() in src/core/shutdown.ts.
    • BootReport.stopWhen, which prints nothing once shutdown has begun and ends start-up with StartupStopped.
    • A closing flag in src/database/connection.ts, so a disconnect that disconnectDatabase asked for is not reported as a lost connection.
  • The dev bot runs @testify/shared from its source.
    • shared/package.json gains an exports map whose development condition points at src/index.ts.
    • npm run dev and dev:all's BOT_WATCH pass --conditions=development.
    • Before this, the dev bot read shared/dist, built just before the watcher started. A branch switched under a running dev:all left it on a build without a new export: Cannot read properties of undefined (reading 'describe') at src/config/instance.ts. On macOS, the watcher also saw that build's write and restarted the bot a second after it started.
    • The built bot is unchanged: plain Node still resolves the require export, shared/dist/index.js.
  • A synced project folder is named, not left to look like a bug. With iCloud's Desktop & Documents turned on, macOS cancels a read of a file still downloading. The bot then crashes with ECANCELED, and the syncing restarts the watcher over and over. dev:all recognises that line (syncedFolderRead) and says once to move the project or end its folder name with .nosync. The README's troubleshooting table says the same for npm run dev.

AGENTS §15 and §24 and the dashboard guide describe the new behaviour. The consumers table in AGENTS §24 now lists the dev bot. Its warning names what still reads shared/dist: the built bot, npm run setup and the docs generators.

Why

The logs said the database had both connected and been lost in the same start. The stale build crashed the dev bot after a branch switch, naming nothing that pointed at the cause.

How to verify

  • npm run check passes.
  • rm -rf dist && npm run build succeeds, and no alias is left unrewritten in dist. The loader smoke test registers 96 commands, 53 buttons, 4 menus and 107 aliases.
  • node -p 'require.resolve("@testify/shared")' gives shared/dist/index.js. With --conditions=development it gives shared/src/index.ts.
  • New tests, each proved red when its fix is removed:
    • startup.test.ts: says nothing once shutting down.
    • connection.test.ts: a disconnect it asked for is not a lost connection.
    • devAll.test.ts: the development condition is in both scripts, and the exports entry points at source.
  • Not verified here: a live run on a Mac in an iCloud-synced folder. The diagnosis comes from the logs, and the fixes are tested in code.

Checklist

  • The branch is cut from develop, and this pull request targets develop
  • npm run check passes
  • Tests cover the new logic
  • No read-modify-save() on numeric fields (no data code touched)
  • Embeds come from the embed() factory (none touched)
  • No raw console.*
  • Every promise is awaited
  • Timers are registered with the timer registry (none added)
  • New custom IDs use the codec and a unique namespace (none added)
  • New environment variables are in src/config/env.ts and scripts/setupEnv.ts (none added)
  • npm run docs:commands re-run if a command changed (no command changed)
  • Documentation updated if behaviour changed

Generated by Claude Code

@Kkkermit
Kkkermit merged commit bd1e3ca into develop Nov 19, 2026
8 checks passed
@Kkkermit
Kkkermit deleted the testify/bugfix-13 branch November 19, 2026 11:15
@Kkkermit Kkkermit mentioned this pull request Nov 19, 2026
13 of 15 tasks
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