Skip to content

[Feature] The per-actor stash capacity is a hardcoded 1024 with no ActorOptions field and no config key #924

Description

@pathosDev

Problem

The per-actor stash capacity is a hardcoded 1024 with no way to change it. _stashCapacity is declared readonly with an initializer and is never assigned from the blueprint, and ActorOptions has no field for it. There is no config key either.

1024 is a reasonable default and a poor ceiling. It is reachable in ordinary use — a PersistentActor stashes every command while recovering, so a slow journal plus a busy entity hits it — and when it is hit the failure is a StashOverflowError thrown from inside the user's handler, which supervision then turns into a restart whose cause is 1024 messages away from the thing that actually went wrong.

Evidence

src/internal/ActorCell.ts:71
const DEFAULT_STASH_CAPACITY = 1024;
src/internal/ActorCell.ts:108
  private readonly _stashCapacity: number = DEFAULT_STASH_CAPACITY;

The field is read at src/internal/ActorCell.ts:539-540 and written nowhere:

src/internal/ActorCell.ts:539-540
    if (this._stashBuffer.length >= this._stashCapacity) {
      throw new StashOverflowError(this._stashCapacity);

src/ActorOptions.ts:29-76 declares supervisorStrategy, dispatcher, mailboxCapacity, mailbox, internal, displayName and entity — no stash field.

Proposal

Add stashCapacity to ActorOptions, wire it through the blueprint next to mailboxCapacity, and give it a config key alongside the default-mailbox block tracked in #862. The naming lockstep the repo uses elsewhere applies: builder withStashCapacity ⇔ field stashCapacity ⇔ HOCON leaf stash-capacity.

Related: #795 covers the typed Behaviors.withStash capacity not being validated; this is the untyped path having no capacity option at all.

Acceptance sketch

  • ActorOptions exposes stashCapacity, honoured by the cell.
  • The value is reachable from HOCON with the usual precedence.
  • The default remains 1024.
  • A PersistentActor with a long recovery can be given headroom without forking the framework.

Verification status

Found in the ten-lens production-readiness review of 2026-08-05 (v0.13.0) and re-verified before filing: confirmed by reading_stashCapacity has exactly one declaration and one read, both cited, and ActorOptions.ts was read in full.

Part of the production-readiness review batch — tracked in #913.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestpriority: lowNice-to-have / niche / demand-drivenproduction-goalBlocks or defines the path to production readiness

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions