@gonzih/cc-discord 0.2.42 → 0.2.43

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -551,13 +551,19 @@ export function createMetaAgentManager() {
551
551
  return; // already running
552
552
  wireRef = wire;
553
553
  startWatchdog();
554
+ // Grace period: don't run stale-instance check until 20s after startup.
555
+ // The instance key write (in index.ts "ready" handler) is async — if the poll
556
+ // loop fires before that write completes, this instance sees the OLD key,
557
+ // incorrectly thinks it's stale, and self-destructs (SIGTERM to all sessions).
558
+ const pollStartTime = Date.now();
559
+ const STALE_CHECK_GRACE_MS = 20_000;
554
560
  pollInterval = setInterval(() => {
555
561
  const namespaces = getNamespaces();
556
562
  if (namespaces.length === 0)
557
563
  return;
558
564
  for (const { namespace: ns, repoUrl } of namespaces) {
559
- // Stale-instance check
560
- if (instanceId) {
565
+ // Stale-instance check — skip during grace period
566
+ if (instanceId && Date.now() - pollStartTime > STALE_CHECK_GRACE_MS) {
561
567
  wire._redis.get(DISCORD_INSTANCE_KEY).then((current) => {
562
568
  if (current && current !== instanceId) {
563
569
  console.log(`[meta-agent-manager] stale instance detected (current=${current}, ours=${instanceId}) — exiting`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gonzih/cc-discord",
3
- "version": "0.2.42",
3
+ "version": "0.2.43",
4
4
  "description": "Claude Code Discord bot — chat with Claude Code via Discord",
5
5
  "type": "module",
6
6
  "bin": {