Skip to content

[bug] Unhandled rejections in fire-and-forget chains kill the whole DSH host (storage boot, execution settlement) #74

Closed

Description

@timacek

What happens

The plugin starts and settles work through fire-and-forget promise chains. Two of them have no
terminal rejection handler, and the installed DSH CLI treats any unhandled rejection as fatal
(installFailLoud in @deepseek-ai/dsh-app-boot: it prints fatal load failure and calls
process.exit(1)), so a single failed write can take down the GUI, every session and the terminal.

1. Storage boot (src/index.ts:76-77, :290)

const storeReady = storage.ready().then(() => store.load())
void storeReady.then(() => assets.cleanup(JSON.stringify(store.snapshot())))
...
void storeReady.then(() => externalSync.start())

storage.ready() is designed to reject (src/host/storage.ts:79, :90-94 —
taskboard_storage_unavailable: configured storage directory is unavailable). Both void storeReady.then(...) chains then reject without a handler.

Trigger needs no attacker: dsh-taskboard-storage.json points at an unmounted USB/network
directory, the folder was deleted or renamed, or DSH_HOME is unwritable at boot. The user cannot
start dsh web at all, and the only message is fatal load failure — nothing names the storage
setting. The plugin's own degraded mode (StorageStatus.error, per-request 500 via the existing
ready guard at src/index.ts:310) is unreachable because the process exits first.

2. Execution settlement (src/host/execution.ts:836-840, same shape at :321-325)

const settle = (): void => {
  if (!this.runs.has(executionId)) return
  this.runs.delete(executionId)
  void this.settleExecution(executionId, sessionId, prepared)   // no .catch
}

settleExecution awaits store.mutate(...) (:869). That write can reject: the ledger lock can
time out (ledger-lock.ts:107, six minutes), or persistAtomic can fail on EBUSY/ENOSPC/EPERM
(Windows rename contention, antivirus, full disk). The run entry is already deleted, so:

  • the process dies on the unhandled rejection (same fail-loud handler);
  • nothing retries: the execution record stays outcome: 'running', the card stays in_progress
    with claimedBy held, while inFlight() reports 0. The card cannot be run again (the gate at
    execution.ts:556 refuses) and the ledger-wide capacity gate (:563-567) keeps counting the
    ghost, so other scheduled dispatches fail with "concurrency limit reached" until someone cancels
    that card by hand.

Verification

  • Storage boot: reproduced with the real StorageCoordinator in a child process (config file →
    non-existent absolute directory) plus a DSH-style unhandled-rejection handler: one rejection,
    fatal message, exit code non-zero.
  • Settlement: in a scratch spec, store.mutate('execution-recorded') was made to reject once after
    run() succeeded; whenIdle then produced one unhandled rejection while the ledger still had
    the running record and the claim, inFlight() was 0.
  • Checked the installed harness: installFailLoud(...) installs process.on('unhandledRejection')
    and exits (it does not just log).

Environment

  • dsh-taskboard 0.9.7 / dev @ fb97e7f (originally reproduced on 0.9.6 @ 3054eba)
  • DSH 0.2.1-rc.5, Windows 11, Node 26.13.0

Suggested fix

Make both chains terminal: void storeReady.then(...).catch(error => console.warn(...)) (and the
same at :290), and keep the settlement promise from leaking:
void this.settleExecution(...).catch(error => console.error('[dsh-taskboard] settlement failed:', error))
while re-registering or retrying the run instead of dropping the entry first. It is worth auditing
the remaining fire-and-forget calls for the same class — with fail-loud hosting, an unhandled
rejection is a process kill, not a log line.

Dedupe

#53 covered stale ledger-lock recovery; #39 covered reconcile marking in-flight runs failed on load.
Neither covers the rejection (and the host exit) itself.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions