Skip to content

fix: upgrade double-lock, flag parsing, and message ordering#277

Merged
BYK merged 1 commit into
mainfrom
fix/upgrade-double-lock-and-flags
May 13, 2026
Merged

fix: upgrade double-lock, flag parsing, and message ordering#277
BYK merged 1 commit into
mainfrom
fix/upgrade-double-lock-and-flags

Conversation

@BYK
Copy link
Copy Markdown
Owner

@BYK BYK commented May 12, 2026

Summary

  • Double-lock bug: downloadBinaryToTemp() acquires a lock then installBinary() tries the same lock when source == target dir. handleExistingLock only allowed re-entry for process.ppid, not process.pid, causing UpgradeError: Another upgrade is already in progress after a successful download, leaving a stale .download file behind.
  • --version / --help flags silently swallowed: The upgrade subcommand didn't declare version or help in its OPTIONS, so parseArgs dropped them. Additionally, top-level CLI intercepted --version before dispatch, so lore upgrade --version nightly just printed the version and exited.
  • Nightly channel not persisted on curl install: LORE_VERSION=nightly curl ... | bash installed the nightly binary but never wrote ~/.lore/channel, so getReleaseChannel() defaulted to "stable" on first run.
  • Message ordering: "Applied delta patch" printed after "Binary verified" — moved into downloadBinaryToTemp() so it appears in chronological order.

Changes

File Change
packages/gateway/src/cli/lib/binary.ts Allow same-process lock re-entry (existingPid === process.pid)
packages/gateway/src/cli/upgrade.ts Add --version, --help to OPTIONS; add help text handler; remove dead formatBytes
packages/gateway/src/cli/main.ts Only handle --version/--help at top level when no subcommand; pass raw args to upgrade
packages/gateway/src/cli/lib/upgrade.ts Print delta patch message before binary verification
docs/install Persist ~/.lore/channel when installing nightly

- Fix acquireLock re-entry: allow same-process PID to re-acquire lock,
  preventing 'Another upgrade is already in progress' when source and
  target install directories are the same path.
- Add --version and --help flags to upgrade subcommand's OPTIONS so
  parseArgs doesn't silently swallow them.
- Don't handle --version/--help at top-level CLI when a subcommand is
  present; pass raw args to upgrade so it can parse its own flags.
- Persist nightly channel in install script when LORE_VERSION=nightly.
- Move 'Applied delta patch' message before 'Binary verified' for
  correct chronological ordering.
- Remove dead formatBytes from upgrade.ts.
@BYK BYK force-pushed the fix/upgrade-double-lock-and-flags branch from 1e548b4 to 7897ea6 Compare May 13, 2026 00:08
@BYK BYK merged commit dfd8915 into main May 13, 2026
7 checks passed
@BYK BYK deleted the fix/upgrade-double-lock-and-flags branch May 13, 2026 00:10
This was referenced May 13, 2026
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