Skip to content

fix(group): bot events in flight when the core stops no longer crash it - #1007

Queued
HelasaZ wants to merge 1 commit into
mtsu-dev:mainfrom
HelasaZ:fix/group-host-flush
Queued

HelasaZ wants to merge 1 commit into
mtsu-dev:mainfrom
HelasaZ:fix/group-host-flush

Conversation

@HelasaZ

@HelasaZ HelasaZ commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Kind of change

  • This is a bug fix, performance, documentation or a new plugin extension point (features go in plugins: docs/plugins.md)

What changed

GroupBotHost.flush awaits the other machine's bot.event answer, then writes to the journal (#drop, outbox) without checking whether the host or the journal closed meanwhile, and the timer calls it with void this.flush(...). A core stopping while bot events were in flight threw RangeError: Cannot use a closed database as an unhandled rejection, which the core treats as fatal.

  • After the await, and in the catch, flush returns once the host is closed or the journal is gone.
  • The timer logs a failed flush instead of leaving it unhandled.

Verification

  • New test in agents-group.test.ts: pc's bot.event request is held, pc stops, then the request returns. It fails on main with RangeError: Cannot use a closed database and passes with this change.
  • bun test packages/core/test/agents-group.test.ts: 14 pass, 0 fail.
  • bun run --cwd packages/core check: clean.
  • Run on Windows 11 only, with bun 1.4.4.

Affected paths

Tick what this change touches and was checked on. Leave the rest empty.

  • Desktop and phone
  • Each affected driver: Claude, ACP, Codex, Muse, pi, agy, echo
  • Both transports: the real core and lib/fake-client.ts
  • Reverse actions: archive, uninstall, unsubscribe, shutdown
  • Windows and Linux
  • Contract first: the domain file in packages/contracts/src/
  • Documentation

…er crash it

`flush` wrote to the journal after awaiting the other machine's answer, with
no check that the host or journal had closed meanwhile, and the timer fired it
with `void`. A core stopping while bot events were in flight threw "Cannot use
a closed database" as an unhandled rejection, which the core treats as fatal.

The flush now stops once the host or journal is gone, and the timer logs any
failure instead of leaving it unhandled.
@github-actions github-actions Bot added the core packages/core and packages/contracts label Nov 10, 2026

@mtsu-patrol mtsu-patrol Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

@mtsu-patrol

mtsu-patrol Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

This stops waiting bot-event deliveries from crashing a core that is shutting down. The pending delivery used to write to the journal after it was closed, raising an unhandled error. Late deliveries are now skipped and timer failures are logged instead.

No comments posted: the reviewers raised no finding.

Review details
  • Model: muse-spark-1.3-contributor
  • Compared commits: 9114d1b to 96abacb
  • Execution: static analysis, no project code was executed
  • Files reviewed: 2 of 2
  • Duration: 3 min 11 s

@HelasaZ
HelasaZ force-pushed the fix/group-host-flush branch from 47770d1 to 96abacb Compare November 11, 2026 15:08

@mtsu-patrol mtsu-patrol Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

@klNuno
klNuno enabled auto-merge November 11, 2026 16:36
@klNuno
klNuno added this pull request to the merge queue Nov 11, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 11, 2026
@klNuno
klNuno added this pull request to the merge queue Nov 11, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 11, 2026
@klNuno
klNuno added this pull request to the merge queue Nov 11, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core packages/core and packages/contracts

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant