App-Raider
view release on metacpan or search on metacpan
.claude/skills/perl-io-async-future/SKILL.md view on Meta::CPAN
- **`await` inside `map`/`grep` does not work.** Convert to a `for` loop with an accumulator.
- **Caller drops the Future** â "Suspended async sub ⦠lost its returning future". The async sub's continuation is destroyed mid-flight. Always store the Future or `await` it.
- The async sub itself does not retain its returning Future. **Storing the Future in the calling object is the cure**, not adding `->retain` inside the async sub.
---
## Pattern 7 â Timeouts
```perl
# delay_future returns a Future that resolves with no value after N seconds
my $timer = $self->loop->delay_future(after => 5);
# Race the work against the timer
my $result = await Future->wait_any(
$work_future,
$timer->then_fail('timeout'),
);
```
`then_fail($msg)` is shorthand for "when the upstream Future is done, fail with this message" â perfect for timeouts. There's also `->timeout($secs)` on Future ⥠0.42.
---
## Pattern 8 â Cancellation Hygiene
```perl
( run in 1.357 second using v1.01-cache-2.11-cpan-817d5f8af8b )