Size / Priority
Rationale
If the SAME message kills the actor N times in a row, it's a poison pill. Restarting forever is unhelpful — better to quarantine the message and keep the actor alive.
Design sketch
// src/internal/PoisonPillDetector.ts (new)
export interface PoisonPillOptions {
/** N identical-message failures before quarantine. Default: 3. */
readonly maxFailuresPerMessage?: number;
/** What to do with quarantined messages: log + drop, or send to DeadLetters. Default: deadletters. */
readonly quarantineAction?: 'log' | 'deadletters';
}
Implementation:
- Per-actor map:
Map<messageDigest, failureCount>.
- On supervision failure: increment count for the offending message.
- When count >= max: drop the message; emit
PoisonPillQuarantined event.
Digest: hash of JSON.stringify(message) (caveats: large messages, non-stringifiable values; document).
Integration
- Supervision: existing pathway.
- Metrics:
actor_poison_pills_total{actor.path}.
- DeadLetters: optional sink.
Out of scope / non-goals
- Cross-actor poison detection — out of scope.
- Strict exactly-same-bytes detection — digest-based is sufficient.
Open design questions
- Digest method: SHA-256 (collision-safe, slow) vs FNV-1a (fast, collision-prone). Recommend FNV-1a (collisions extremely unlikely + speed matters).
- Cap on tracking map size: bounded LRU.
Test plan
- Send panic message 3× → restart 3× → 4th time quarantined; actor alive.
- Different messages don't accumulate together.
- Quarantined message in DeadLetters.
- Metric increments.
- Map size capped.
Acceptance criteria
Size / Priority
Rationale
If the SAME message kills the actor N times in a row, it's a poison pill. Restarting forever is unhelpful — better to quarantine the message and keep the actor alive.
Design sketch
Implementation:
Map<messageDigest, failureCount>.PoisonPillQuarantinedevent.Digest: hash of
JSON.stringify(message)(caveats: large messages, non-stringifiable values; document).Integration
actor_poison_pills_total{actor.path}.Out of scope / non-goals
Open design questions
Test plan
Acceptance criteria
PoisonPillOptionsper actor.