Skip to main content
protected despawn(child): Promise<void>
End one child of this agent — both halves, in one call. A child that is finished has to be emptied and removed, and doing only one leaves a mess of a specific kind. Emptying alone leaves the name alive: the next call to it activates a blank agent that answers as if it were new. Removing alone leaves everything the child accumulated — its state, its pending timers, its history — sitting in storage under a name nothing can reach again. despawn() does both, in the order that works: the child empties itself first, while it can still be reached, and only then is the name ended. Afterwards a call to the old address is refused rather than answered by a ghost.
Pass the name, or the stub you were handed when the child was created — either identifies the same child. A stub is read for the child it names, not for how to reach it: the child is addressed by the type the platform says it runs as, so a stub minted from the wrong binding still ends the right child rather than emptying one actor and removing another. A name that is not one of this agent’s children is not an error: it is already in the state being asked for, so the call returns having done nothing. That makes a retry after a partial failure safe. Only this agent’s own children can be ended this way. Naming somebody else’s child, or an instance that was never a child at all, does nothing. Added with SDK 0.15 — a new inherited member, so a subclass that already declares despawn must rename it (or align it to override this method). Parameters Returns Promise<void>